28 Nov 2015

Getting "com.android.dex.DexException: Multiple dex files define"

One of the issues in the new Gradle build system is that you can often get "Multiple dex files define" issues.

If a library is included twice as a dependency you will encounter this issue. Review the libs folder for JARS and the gradle file at app/build.gradle and see if you can identify the library dependency that has been loaded into your application twice.

If one dependency library already includes an identical set of libraries, then you may have to make changes to your Gradle configurations to avoid this conflict. This problem usually happens when there are multiple third-party libraries integrated into your code base.

Another error if you attempt to include a library that is a subset of another library. For instance, suppose we included the Google play-services library but thought we also needed to include it with the play-services-map library.:

dependencies {
    compile 'com.google.android.gms:play-services:6.5.+'
    compile 'com.google.android.gms:play-services-maps:6.5.+'
}

It turns out that having both is redundant and will cause errors. It is necessary in this case to remove one or the other, depending on your need to use other Google API libraries.

No comments:

Post a Comment