. Advertisement .
..3..
. Advertisement .
..4..
Hi everyone. When running builds in Android Studio, the following build errors”execution failed for task ‘:app:transformdexarchivewithexternallibsdexmergerfordebug'” were encountered:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex"
The file of my app:build.gradle :
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
testCompile 'junit:junit:4.12'
}
configurations.all {
resolutionStrategy {
force 'com.android.support:appcompat-v7:26.0.1'
force 'com.android.support:support-compat:26.0.1'
force 'com.android.support:support-core-ui:26.0.1'
force 'com.android.support:support-annotations:26.0.1'
force 'com.android.support:recyclerview-v7:26.0.1'
}
}
apply plugin: 'com.google.gms.google-services'
I have reseached many information sources, but I cound find the solution to fix this error. If you know the answer, please help me. Thanks a lot.
The cause:
When you add an external library that might not be compatible with your
compileSdkVersion
, this error occurs:When including an
external library
, you should take care of it.The solution:
I took few days to study this problem, and you can do this way:
Ensure that all of your reference libraries
compileSdkVersion
of yourbuild.gradle(Module:app)
. For example it is26
of mine.In the defaultConfig category type multiDexEnabled true. This part had to do.
Click okay after trying to enable or disable Instant Run to hot swap in File | Settings | Build, Execution, Deployment | Instant Run.
Sync