I have this android project that worked well. My idea was that I was going to use an already-existing Google Sheets as my database for the app. I searched and searched until I found an example. So I added
- gdata-client-1.0.jar
- gdata-client-meta-1.0.jar
- gdata-core-1.0.jar
- gdata-spreadsheet-3.0.jar
- gdata-spreadsheet-meta-3.0.jar
- guava-11.0.2.jar
Then the error came up:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
So I tried using
multiDexEnabled true
which worked well (successful gradle) until I ran the project.
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [E:\AndroidStudioProjects\Corporate Outcome Request System (CORS)\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\hp.gradle\caches\modules-2\files-2.1\com.google.guava\guava-jdk5\17.0\463f8378feba44df7ba7cd9272d01837dad62b36\guava-jdk5-17.0.jar(;;;;;;**.class)] (Duplicate zip entry [guava-jdk5-17.0.jar:com/google/common/annotations/Beta.class]))
This is my build.gradle now:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.YearZero.CORS"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'pub.devrel:easypermissions:0.3.0'
compile 'com.android.support:multidex:1.0.2'
compile('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-sheets:v4-rev496-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
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'
}
There were also instances where I got transformClassesWithMultidexlistForDebug and transformClassesWithDexlistForDebug :P
Here's what I have found regarding your type of error. I am giving examples similar to your case.
Solution
Try place the following
exclude group: 'com.google.guava'in either the com.google.api-client:google-api-client-android:1.23.0 or com.google.apis:google-api-services-sheets:v4-rev496-1.23.0 and see what happens.In some cases:
build.gradlecontain different versions of the same dependency e.g one dependency usesplay-services:11.6.0and anotherplay-services:11.6.1gradle may not know how to merge them. Another example could be you have'com.android.support:appcompat-v7:26.1.0but your design library may be using an older version e.g'com.android.support:design:25.0.0'build.gradlethat create the conflict mentioned in (step 1). The simple solution here is to uninstall on your device and reinstall