Migrate the Eclipse ADT project to Android Studio: Error Several dex files define Lan…

I have an old Android project made with Eclipse ADT and I’m trying to migrate it to Android Studio. I follow several guides and howtos and maybe I have almost migrated it.

When I try to build it I get the following error:

Error:Error converting bytecode to dex:Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

I have read a lot of solutions but none seems to suit to my problem. But maybe this answer is for my case…

Here is the Project status in Eclipse project explorer:

and here is the migrated Project in Android Studio project view:

Maybe the problem is the dependencies property of every gradle script:

app-app:

dependencies {
    compile project(':androidsupportv7appcompat')
    compile project(':library')
    compile files('libs/android-support-v4.jar')
}

androidsupportv7appcompat:

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/android-support-v7-appcompat.jar')
}

googleplayservice_lib:

dependencies {
    compile files('libs/google-play-services.jar')
}

library:(a Google Maps library for markers clustering)

dependencies {
    compile project(':googleplayservices_lib')
    compile files('libs/android-support-v4.jar')
}

Do you know if something could be wrong in these dependencies configurations? Otherwise, what could be the cause?

First of all, you should remove the Support Library module from your Android Studio project. Instead add a dependency to your apps gradle build file. If your library uses components from the support library, its build file should have the proper dependencies also.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
}

Be sure to remove the Support Library JAR files from your lib’s folder.

Similarly you should add a dependency for Google Play Services.

Dependency management with Gradle is one of the many advantages of moving to Android Studio. If the library module is not written by you, you should also find the correct take dependency to add to your build file instead of the module you have now.

Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 移动开发 » Migrate the Eclipse ADT project to Android Studio: Error Several dex files define Lan…

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录