gpt4 book ai didi

java - multidex 应用程序在尝试运行仪器测试时出现 ZipException : duplicate entry for junit,

转载 作者:行者123 更新时间:2023-12-01 23:53:07 27 4
gpt4 key购买 nike

尝试运行仪器测试时,出现此错误:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'.
com.android.build.api.transform.TransformException:
java.util.zip.ZipException:
duplicate entry:
org/junit/ClassRule.class

但有时重复条目是:

        duplicate entry:
junit/extensions/ActiveTestSuite$1.class

这显然是正确的:Control-N -> 输入ClassRule 显示:

  1. C:\Users\me\.gradle\caches\modules-2\files-2.1\junit\junit\4.12\a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa\junit-4.12-sources.jar!\org\junit\ClassRule.java
  2. C:\Users\me\.gradle\caches\modules-2\files-2.1\junit\junit-dep\4.10\64417b3bafdecd366afa514bd5beeae6c1f85ece\junit-dep-4.10.jar!\org\junit\ClassRule .class(反编译的.class文件,字节码版本:49.0(Java 5.0)

搜索ActiveTestSuite给出3个结果,全部位于C:\Users\me\.gradle\caches\modules-2\files-2.1\junit\

>

有没有办法查看依赖关系图?我评论了 app/build.gradle 的依赖项部分中所有相关的 junit:

dependencies {
compile 'com.android.support:multidex:1.0.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
/// <Dagger>
provided 'javax.annotation:jsr250-api:1.0'
apt 'com.google.dagger:dagger-compiler:2.0.1'
compile 'com.google.dagger:dagger:2.0.1'
compile 'com.google.dagger:dagger-compiler:2.0.1'
/// </Dagger>

// ------ JSON ... ------
testCompile 'org.glassfish:javax.json:1.0.4'
testCompile 'com.fasterxml.jackson.core:jackson-databind:2.7.4'
// ------ ... JSON end ------
apt 'com.jakewharton:butterknife-compiler:8.0.1'

//testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.robolectric:robolectric:3.0'
//androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'org.robolectric:robolectric:3.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2'){
exclude group: 'javax.inject'
}

compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v13:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.jakewharton:butterknife:8.0.1'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.5'
//<Floating Buttons>
compile 'com.github.clans:fab:1.6.4'
//</Floating Buttons>
compile 'org.apache.commons:commons-lang3:3.4'
}

最佳答案

您需要做的就是将以下行添加到我们的依赖项列表中:

 testCompile "junit:junit:4.12'

然后,通过在 app/build.gradle 中添加以下 block ,强制此版本的 Junit 依赖于整个项目:

configurations.all{
resolutionStrategy.force 'junit:junit:4.12'
}

这将解决您所有的依赖冲突。

欲了解更多信息: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

关于java - multidex 应用程序在尝试运行仪器测试时出现 ZipException : duplicate entry for junit,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37865212/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com