本文介绍了Espresso-web导入导致duplicateFileException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Espresso。我需要espresso-web才能使用webviews。我根据谷歌网站设置了我的咖啡。



我的依赖性看起来像:

$ $ $ $ $ $


$ android $ android_statecompile'junit:junit:4.12'
androidTestCompile' com.squareup.spoon:spoon-client:1.1.10'
androidTestCompile'c​​om.jraska:falcon-spoon-compat:0.3.1'
androidTestCompile'c​​om.android.support:support-annotations: 23.1.1'

androidTestCompile 'com.android.support.test:亚军:0.4.1'
androidTestCompile 'com.android.support.test:规则:0.4.1'
androidTestCompile'c​​om.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile'c​​om.android.support.test.espresso:espresso-web:2.2.1'

androidTestCompileorg.mockito:mockito-core:1.10.1 9
androidTestCompilecom.google.dexmaker:dexmaker:1.2
androidTestCompilecom.google.dexmaker:dexmaker-mockito:1.2
}

当我评论espresso-web imports / methods并排除这个lib时,测试运行。但有了它,我得到:

pre $ 错误:任务':app:transformResourcesWithMergeJavaResForDebugAndroidTest'的执行失败。
> com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在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

似乎是番石榴的一些问题。 Espress-web lib生成两个文件夹:espresso-web,espresso-core。意式咖啡核心库也生成意式咖啡核心,它们似乎重叠 - 但这就是安装程序所说的。排除Espresso-core lib对此没有帮助。任何想法如何解决它?



编辑:



在packagingOptions解决方法现在:

  exclude'META-INF / maven / com.google.guava / guava / pom.properties'
exclude'META-INF / maven / com.google.guava /番石榴/ pom.xml的


解决方案

尝试其他周围的方式。不要使用espresso-core,而要使用espresso-web。示例:


I am using Android Espresso. I needed espresso-web to work with webviews. I set my espresso according to google website.

https://google.github.io/android-testing-support-library/downloads/index.html

My dependencies looks like that:

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"
}

When I comment espresso-web imports/methods and exclude this lib then tests run. But with it I get:

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

Seems to be some problem with guava. Espress-web lib generates both folders: espresso-web, espresso-core. Espresso-core lib also generates espresso-core and they seem to overlap - but that's how setup says it should be. Excluding Espresso-core lib doesn't help there. Any idea how to fix it?

Edit:

Workaround for now in packagingOptions:

exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
解决方案

Try the other way around. Do not use espresso-core but just espresso-web. Example:

Espresso Official Test Kit Blog Example

这篇关于Espresso-web导入导致duplicateFileException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 04:08