0

I installed retrofit2 in Android Project using following gradle lines;

compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'

In the first attempt, the following error is occurred.

enter image description here

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

After that, I added following line under defaultConfig

multiDexEnabled true

As a result of this, the following error is occured.

enter image description here

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class

Finally, I tried this (Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug') solution, but the result is same.

How can I solve this problem?

Community
  • 1
  • 1
Berkay Yildiz
  • 595
  • 7
  • 23

1 Answers1

1

I found the solution. If you exclude the gson module from converter-gson, It works.

Like this;

dependencies {
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile ('com.squareup.retrofit2:converter-gson:2.0.0-beta4'){
        exclude module: 'gson'
    }
}
Berkay Yildiz
  • 595
  • 7
  • 23