0

I execute Gradle command inside android studio terminal for running project tests.

./gradlew connectedCheck --stacktrace

I got the following error :

:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources
:app:transformClassesWithJarMergingForDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task   ':loginsdk:transformClassesWithJarMergingForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/mockito/AdditionalAnswers.class

Try:
 Run with --info or --debug option to get more log output.

Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'.

 Caused by: com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/mockito/AdditionalAnswers.class
    at com.android.build.gradle.internal.transforms.JarMergingTransform.transform(JarMergingTransform.java:123)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:151)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:148)
    at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55)
    ... 69 more
Caused by: java.util.zip.ZipException: duplicate entry: org/mockito/AdditionalAnswers.class
    at com.android.build.gradle.internal.transforms.JarMerger.addJar(JarMerger.java:143)
    at com.android.build.gradle.internal.transforms.JarMergingTransform.transform(JarMergingTransform.java:113)
    ... 72 more


  BUILD FAILED
halfer
  • 19,824
  • 17
  • 99
  • 186
RajeshVijayakumar
  • 10,281
  • 11
  • 57
  • 84
  • Hi Rajesh. Please do not add "urgent", "ASAP" or any other forms of help begging to your questions. **Volunteers** here will answer questions they find interesting, at their leisure. – halfer Dec 30 '15 at 19:50

1 Answers1

3

Also ran into this problem today. My log is similar.

:app:transformClassesWithJarMergingForDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/hamcrest/MatcherAssert.class

i found my own culprit. It was

androidTestCompile 'com.android.support.test:testing-support-lib:0.1'

which is obsolete and causing duplication with

androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'

I removed the former and the error is gone.

CatFly
  • 440
  • 1
  • 3
  • 11