Ghirma Ghirma - 18 days ago 10
Android Question

java.util.zip.ZipException with retrofit 2

I'm having

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
>com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: retrofit2/BuiltInConverters$BufferingResponseBodyConverter.class


I can't understand from where this error come and why

Appaered whe i added gson converter from retrofit2

I already clean the project

my gradle

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 files('libs/gson-2.7.jar')
// compile files('libs/okhttp-3.4.1.jar')
//compile files('libs/okio-1.11.0.jar')

compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-maps:9.2.1'
testCompile 'junit:junit:4.12'
}

Answer
//compile files('libs/gson-2.7.jar')
// compile files('libs/okhttp-3.4.1.jar')
//compile files('libs/okio-1.11.0.jar')

You commented these, but those are still being compiled

compile fileTree(dir: 'libs', include: ['*.jar'])

You need to actually remove the jar files if you do not want to compile them. In other words, make sure you don't have any retrofit related jar files in the libs folder

Comments