com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex - Android Studio 3.0 stable
I know it's too late to update.I had same issue on my project.
Possible Reasons
- If you have added module in your project and that module has support libraries or any google play services libs which has different version then your app.
- If you are using any open source library in your project and that library internally using any of libraries that your are also using in your project.
Solutions
- If it is case 1 in your project then update your library versions and make it same in your project and module.
Check your dependencies tree using below command and see if any mismatch in dependencies.
./gradlew :app:dependencies
You can exclude particular module from any dependencies like below.
implementation('com.google.android.ads.consent:consent-library:1.0.4') { transitive = true exclude group: "com.android.support" }
In above example, It will exclude the com.android.support group from consent-library dependencies.
You can also remove particular module as well.
compile ('junit:junit:4.12'){ exclude group: 'org.hamcrest', module:'hamcrest-core' }
In above example it will exclude hamcrest-core from org.hamcrest.
- Go to
<project>/app/
and openbuild.gradle
file - Add the following line to the
defaultConfig
anddependencies
sections
android {
...
defaultConfig {
...
multiDexEnabled true // ADD THIS LINE
}
}
...
dependencies {
...
implementation 'com.android.support:multidex:1.0.3' // ADD THIS LINE
}
I got the same problem, adding sourceCompatibility
and targetCompatibility
to my build.gradle
helped me:
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}