我正在使用Android Espresso。我需要使用Contrib和Web,因此这里的解决方案对我不起作用。 Link
我收到此错误。
Error:Execution failed for task ':transformResourcesWithMergeJavaResForQaDebugAndroidTest'.
com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK META-INF / maven / com.google.guava / guava / pom.xml中复制的重复文件 File1:C:\ Users \ jwhit \ ASProjects \ v2.0 \ build \ intermediates \ explosion-aar \ com.android.support.test.espresso \ espresso-web \ 2.2.1 \ jars \ classes.jar File2:C:\ Users \ jwhit \ ASProjects \ v2.0 \ build \ intermediates \ explosion-aar \ com.android.support.test.espresso \ espresso-core \ 2.2.1 \ jars \ classes.jar
这些已添加到我的gradle中,如下所示。
dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile 'com.android.support:support-annotations:23.2.0'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.1')
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.1'){
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
}
答案 0 :(得分:3)
我找到了解决方法。将其添加到gradle构建的android部分
android{
packagingOptions {
pickFirst('META-INF/maven/com.google.guava/guava/pom.xml')
pickFirst('META-INF/maven/com.google.guava/guava/pom.properties')
}
}
我希望有人觉得这很有用。