Android Studio. I'm getting this kind of error during application run.
Error:Execution failed for task ':app:packageDebug'. Duplicate files copied in APK META-INF/notice.txt
build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
compile 'com.octo.android.robospice:robospice:1.4.11'
compile 'com.octo.android.robospice:robospice-spring-android:1.4.11'
}
How can I fix this error?
EDITED
These exclude options solved my problem:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
Short Answer:
See the detailed gradle output using
gradle assemble
and note the files that are duplicate and exclude them using:Long Answer:
Run the
assemble
gradle task from command line for detailed output:./gradlew assemble || gradle assemble
This automatically shows what to exclude:
See this part in output:
It even shows the list of dependencies which originated duplicate files (LICENSE). See the lines with Origin # in the output.
Interestingly, when I deleted this line from gradle, it worked:
I think the string comparison is case sensitive. try with
exclude 'META-INF/notice.txt'
It's more than one error, you are right.
Under
apply plugin: 'android-library'
add this ::
android { packagingOptions { exclude 'META-INF/ASL2.0' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } }
1st error is by file duplicates, 2nd is by LICENSE and NOTICE files. It will work after
EDIT:: See my post here about identifying the problems:: Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"
I had to play around a bit to find the right location for the packagingOptions. Solving the duplicate file problem for a conflict between jackson-core:2.2.2 and jackson-databind:2.2.2 Also the DSL seems to have changed recently So in the recent Android Studio 1.4.1 with buildTools 23 you have to put android.packaging options on the same level as compileOptions AND NOT inside any model { android { braces !
}
I think you need to include only these options in build.gradle: