Java.Lang.Runtimeexception: Com.Android.Builder.Dexing.Dexarchivemergerexception: Unable to Merge Dex in Android Studio 3.0

Unable to Merge Dex - Android Studio 3.0.1 DexArchiveMergerException

I have solved after try all the solutions on stackoverflow, try to do the following steps in its order

  1. Replace all compile with implementation
  2. Make all supportLibraryVersion = '27.0.2'
  3. Change

'com.google.android.gms:play-services-maps:11.8.0'

to

'com.google.android.gms:play-services-maps:11.4.0'


  1. Remove all the unused library
  2. Delete the .gradle folder inside your project
  3. Remove build folders and the gradle cache
  4. file -> invalidate caches/restart
  5. Build > Clean Project
  6. Add

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


  1. Add

android {
defaultConfig {
multiDexEnabled true
}
}


  1. Async project

And finally this is my App file

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}
ext {
supportLibraryVersion = '27.0.2'

}
dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'

//constraint
implementation 'com.android.support.constraint:constraint-layout:1.0.2'

//butterknife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//avi:library
implementation 'com.wang.avi:library:2.1.3'

//circleimageview
implementation 'de.hdodenhof:circleimageview:2.2.0'

//retrofit2
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
implementation 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.0.2'

//recyclerview and cardview
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'

//ZXing for barCode reader
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
implementation 'com.google.zxing:core:3.2.1'

//play-services
implementation 'com.google.android.gms:play-services-maps:11.4.0'

//gson
implementation 'com.google.code.gson:gson:2.8.2'
//statusbarutil
implementation 'com.jaeger.statusbarutil:library:1.4.0'
//glide
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
//multidex
implementation 'com.android.support:multidex:1.0.1'
}

ِِActually I didn't understand the real reason about it and why that happened suddenly

So if anyone know that please tell me with full details

I hope this will help you

com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

change to

compilsdkVersion 29  
minSdkVersion 15
targetSdkVersion 29

com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex - Android Studio 3.0 stable

I think it was due to Android Studio's latest version (at that time).
I tried it after a long time then the issue gone.

Unable to Merge Dex after upgrading to Android Studio 3.0

Caused by: com.android.dex.DexException: Multiple dex files define Lcom/ogaclejapan/smarttablayout/utils/ViewPagerItems$Creator;

My guess is that you are not supposed to be using all three of these, but rather only one or two of them:

implementation 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
implementation 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'
implementation 'com.ogaclejapan.smarttablayout:utils-v13:1.6.1@aar'

Unable to Merge-Dex

The transform dex merger issue was persistent.. Until I added a dependency ::

implementation 'android.arch.lifecycle:extensions:1.1.0'

DexArchiveMergerException: Unable to merge dex - Android Studio 3.0 Stable

Add

implementation('commons-validator:commons-validator:1.4.1') {
exclude group: 'commons-collections', module: 'commons-collections'
}

instead of

implementation'commons-validator:commons-validator:1.4.1'

The reason I've tried to explain here if you want to understand the issue and solution.

Hope it solves your issue.

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex in Android Studio 3.0

Enable Multidex through build.gradle of your app module

multiDexEnabled true

Same as below -

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.xx.xxx"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true //Add this
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

Then follow below steps -

  1. From the Build menu -> press the Clean Project button.
  2. When task completed, press the Rebuild Project button from the Build menu.
  3. From menu File -> Invalidate cashes / Restart

compile is now deprecated so it's better to use implementation or api



Related Topics



Leave a reply



Submit