Issue
i`m using Android-Studio 2.2.2 and did my first try using espresso for testing. With the attached build.gradle i got these error-message:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK junit/runner/smalllogo.gif
File1: /home/christian/AndroidStudioProjects/PinMoney/app/libs/junit-4.12.jar
File2: /home/christian/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar
Here is the app gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
def AAVersion = '4.1.0'
android {
compileSdkVersion 25
buildToolsVersion "25"
defaultConfig {
applicationId "de.cokuss.chhe.pinmoney"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENCE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile files('libs/junit-4.12.jar')
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude group: 'com.android.support'
}
androidTestCompile ('com.android.support.test:runner:0.5') {
exclude group: 'com.android.support'
}
}
I have found several "Duplicate files copied" problems while searching but always with different files. Just adding
packagingOptions {
exclude 'LICENCE.txt'
exclude 'smalllogo.gif' //added
}
does not help.
Solution
This:
packagingOptions {
exclude 'LICENCE.txt'
exclude 'smalllogo.gif' //added
}
was not the right solution, but with a little help from the Internet i found out that i had to make it more exact. Also i found out that smalllogo.gif was not the only thing i had to exclude. Here is the important part i had to change:
packagingOptions {
exclude 'LICENCE.txt' // from old code
exclude 'junit/runner/smalllogo.gif'
exclude 'junit/runner/logo.gif'
exclude 'LICENSE-junit.txt'
}
I don`t think that this is the best way to fix this problem, but it works.
Answered By - ChrisBee
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.