我正在使用Android Espresso。我需要使用Contrib和Web,因此這裏的解決方案對我無效。 Link使用Contrib和Web Espresso導入會導致duplicateFileException
我得到這個錯誤。
Error:Execution failed for task ':transformResourcesWithMergeJavaResForQaDebugAndroidTest'.
com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:重複的文件在APK META-INF複製/行家/ com.google.guava /番石榴/ pom.xml File1:C:\ Users \ jwhit \ ASProjects \ v2.0 \ build \ intermediates \ exploded-aar \ com.android.support.test.espresso \ espresso-web \ 2.2.1 \ jars \ classes.jar File2:C:\ Users \ jwhit \ ASProjects \ v2.0 \ build \ intermediates \ exploded-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'
}
}