Espresso-web 导入导致 duplicateFileException
Espresso-web import causes duplicateFileException
我正在使用 Android 浓缩咖啡。我需要 espresso-web 来处理 webviews。我根据 google 网站设置了浓缩咖啡。
https://google.github.io/android-testing-support-library/downloads/index.html
我的依赖项看起来像这样:
dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.squareup.spoon:spoon-client:1.1.10'
androidTestCompile 'com.jraska:falcon-spoon-compat:0.3.1'
androidTestCompile 'com.android.support:support-annotations:23.1.1'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.1'
androidTestCompile "org.mockito:mockito-core:1.10.19"
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
}
当我评论 espresso-web imports/methods 并排除这个库然后测试 运行。但有了它我得到:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.google.guava/guava/pom.properties
File1: /Users/F1sherKK/Dev/MyProject/app/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-web/2.2.1/jars/classes.jar
File2: /Users/F1sherKK/Dev/MyProject/app/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.2.1/jars/classes.jar
番石榴似乎有问题。 Espresso-web lib 生成两个文件夹:espresso-web、espresso-core。 Espresso-core lib 也生成 espresso-core 并且它们似乎重叠 - 但设置应该如此。排除 Espresso-core lib 并没有帮助。知道如何解决吗?
编辑:
packagingOptions 中的解决方法:
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
反过来试试。不要使用 espresso-core 而只是 espresso-web。示例:
添加
packagingOptions {
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
}
build.gradle 文件对我有用。
我正在使用 Android 浓缩咖啡。我需要 espresso-web 来处理 webviews。我根据 google 网站设置了浓缩咖啡。
https://google.github.io/android-testing-support-library/downloads/index.html
我的依赖项看起来像这样:
dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.squareup.spoon:spoon-client:1.1.10'
androidTestCompile 'com.jraska:falcon-spoon-compat:0.3.1'
androidTestCompile 'com.android.support:support-annotations:23.1.1'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.1'
androidTestCompile "org.mockito:mockito-core:1.10.19"
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
}
当我评论 espresso-web imports/methods 并排除这个库然后测试 运行。但有了它我得到:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.google.guava/guava/pom.properties
File1: /Users/F1sherKK/Dev/MyProject/app/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-web/2.2.1/jars/classes.jar
File2: /Users/F1sherKK/Dev/MyProject/app/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.2.1/jars/classes.jar
番石榴似乎有问题。 Espresso-web lib 生成两个文件夹:espresso-web、espresso-core。 Espresso-core lib 也生成 espresso-core 并且它们似乎重叠 - 但设置应该如此。排除 Espresso-core lib 并没有帮助。知道如何解决吗?
编辑:
packagingOptions 中的解决方法:
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
反过来试试。不要使用 espresso-core 而只是 espresso-web。示例:
添加
packagingOptions {
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
}
build.gradle 文件对我有用。