Retrofit2 Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' - android

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.
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.
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?

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'
}
}

Related

"C:\dev\sdk\android-sdk-essential\build-tools\24.0.1\aapt.exe" finished with non-zero exit value 1

How can I solve this error:
> Error:Execution failed for task ':app:processDebugResources'. >
> com.android.ide.common.process.ProcessException:
> org.gradle.process.internal.ExecException: Process 'command
> 'C:\dev\sdk\android-sdk-essential\build-tools\24.0.1\aapt.exe''
> finished with non-zero exit value 1
Try to do build apk first then afterwards it will work properly.
It solved!
I found a hint in this link. so I commented useless repositories such as:
// compile 'com.google.android.gms:play-services-ads:11.0.4'
// compile 'com.google.android.gms:play-services-auth:11.0.4'
// compile 'com.google.android.gms:play-services-gcm:11.0.4'

Error: Execution failed for task app:transformClassesWithDexForDebug

I am getting this error when I'm going to build apk.
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 'C:\Program Files\Java\jdk1.8.0_91\bin\java.exe'' finished with non-zero exit value 3
Here's the screenshot of the error
My problem is solved by using multidex. By adding multiDexEnabled true in defaultConfig and compile 'com.android.support:multidex:1.0.0'
in dependencies in build gradle in app and adding android:name="android.support.multidex.MultiDexApplication" in manifest. Check out screen shots 2:
1:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'

When I run InstrumentationTest,It's build failed.The error message:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/test/InstrumentationRegistry.class
Somebody tell me why?thank you for you notice
It's just miss words in build.gradle :
packagingOptions {
exclude 'LICENSE.txt'
}
But when I add those words,build failed too,and report other error message :
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/test/BuildConfig;
Error:Execution failed for task ':app:transformClassesWithDexForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' finished with non-zero exit value 2

Execution failed for task ':app:transformClassesWithDexForDebugAndroidTest'. > com.android.build.api.transform.TransformException

here is my full code, when I run following code with "Run/Debug configurations > Android Tests"
class KernelTest extends Specification {
def "match"() {
given:
println("smth");
}
}
I get error:
Execution failed for task ':app:transformClassesWithDexForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/jdk8/bin/java'' finished with non-zero exit value 3
here is full output
how to fix it?
update
I have check the question, but I don't know which jar is duplicated
See the full output, the reason is about groovy, I remove all groovy dependencies and work well

android: Error:Execution failed for task ':app:dexDebug'.Process finished with non-zero exit value 2

when I compile mapbox my project will have a error.
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4#aar'){
transitive=true
}
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
I tried to use multiDexEnabled true, but it doesn't work.
And I tried to find the same .jar files, I think it is 'com.android.support:support-v4:22.2.0',I delete it and no work.
I don't know how to solve it, please help.

Categories

Resources