Issue
I'm trying to use Android Espresso Web for my automation test.
After adding it to the build.gradle file like shown below, I get a "DuplicateFileException" exception.
According to the API, both of the dependancies should be present in the build.gradle file so I don't understand why I get a duplication exception and how to solve it.
Error:Execution failed for task ':CompanyAAA:transformResourcesWithMergeJavaResForStagingDebugAndroidTest'.
> 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/mayabechler-speicher/CompanyAAA-Android/CompanyAAA/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-web/2.2.2/jars/classes.jar
File2: /Users/mayabechler-speicher/CompanyAAA-Android/CompanyAAA/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.2.2/jars/classes.jar
[4:24]
// Espresso core
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// Espresso web
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
Any idea how to solve this error?
Solution
According to Google's Android Testing Support Library Examples, you don't need to declare both, if your existing app depends on webviews.
Check this configuration:
apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion rootProject.buildToolsVersion defaultConfig { applicationId "com.example.android.testing.espresso.web.BasicSample" minSdkVersion 10 targetSdkVersion 24 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } lintOptions { abortOnError false } productFlavors { } packagingOptions { exclude 'META-INF/maven/com.google.guava/guava/pom.properties' exclude 'META-INF/maven/com.google.guava/guava/pom.xml' } } dependencies { // App dependencies compile 'com.android.support:support-annotations:' + rootProject.supportLibVersion; compile 'com.google.guava:guava:18.0' // Testing-only dependencies // Force usage of support annotations in the test app, since it is internally used by the runner module. androidTestCompile 'com.android.support:support-annotations:' + rootProject.supportLibVersion; androidTestCompile 'com.android.support.test:runner:' + rootProject.runnerVersion; androidTestCompile 'com.android.support.test:rules:' + rootProject.rulesVersion; androidTestCompile 'com.android.support.test.espresso:espresso-web:' + rootProject.espressoVersion; }
If you need both, open your build.gradle file and add:
packagingOptions {
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
}
It should work
Answered By - piotrek1543
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.