Android 工作室:transformClassesWithJarMergingForDebugAndroid测试失败
Android Studio : transformClassesWithJarMergingForDebugAndroidTest FAILED
我在 android 工作室终端内执行 Gradle 命令以进行 运行 项目测试。
./gradlew connectedCheck --stacktrace
我收到以下错误:
: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.call(TransformTask.java:151)
at com.android.build.gradle.internal.pipeline.TransformTask.call(TransformTask.java:148)
at com.android.builder.profile.ThreadRecorder.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
今天也运行遇到这个问题。我的日志类似。
: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
我找到了自己的罪魁祸首。这是
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
已过时并导致与
重复
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'
我删除了前者,错误消失了。
我在 android 工作室终端内执行 Gradle 命令以进行 运行 项目测试。
./gradlew connectedCheck --stacktrace
我收到以下错误:
: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.call(TransformTask.java:151)
at com.android.build.gradle.internal.pipeline.TransformTask.call(TransformTask.java:148)
at com.android.builder.profile.ThreadRecorder.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
今天也运行遇到这个问题。我的日志类似。
: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
我找到了自己的罪魁祸首。这是
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
已过时并导致与
重复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'
我删除了前者,错误消失了。