1

I upgraded the android studio 2.x.x to android studio 3.0.1 after importing the project gradle building is successful. But when installing app showing the error message

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

my app grdle is given below

Why it's showing this error and how to fix it? unable to install the app on the emulator.

Already tried the clean and rebuild option in android studio but it doesn't fix the issue

Rakesh
  • 55
  • 2
  • 9
  • Possible duplicate of [java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex in Android Studio 3.0](https://stackoverflow.com/questions/47187662/java-lang-runtimeexception-com-android-builder-dexing-dexarchivemergerexception) – Abhishek Aryan Nov 24 '17 at 05:11
  • try cleaning project and build again – Aswin P Ashok Nov 24 '17 at 05:26

2 Answers2

4

Try with the following

If your minSdkVersion is set to 21 or higher

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...
}

if your minSdkVersion is set to 20 or lower,

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

If this does not resolve, try through these posts post 1 , android_dev or post 2

Sreehari
  • 5,621
  • 2
  • 25
  • 59
0

To remove this Dex issue just implement one dependency. This issue occur when we are using multiple different service from the same server. Suppose we are using ads and Firestore in a project and both have a repository maven. so we need to call different data with on repository we need dex dependency to implement. The new update Dependency:-

 implementation 'com.android.support:multidex:1.0.3'

or use testCompile inside compile such as :

implementation 'com.google.android.gms:play-services-ads:15.0.1'
    testCompile 'com.google.firebase:firebase-firestore:17.0.1'

and also make multiDexEnabled true; 100 % it will work !

Pradeep Sheoran
  • 493
  • 6
  • 15