Android : Error:duplicate files during packaging of APK

on Monday, October 27, 2014


I've got a library module (with resources) and an example modules that attempts to use the library. I can't get them to build, I get the following error from Gradle:



Error:duplicate files during packaging of APK /x/x/x/x/x/x/example/build/outputs/apk/example-debug-unaligned.apk
Path in archive: resources.arsc
Origin 1: /x/x/x/x/x/x/example/build/intermediates/libs/example-debug.ap_
Origin 2: /x/x/x/x/x/x/library/build/outputs/apk/app-release-unsigned.apk
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'resources.arsc'
}
}


It makes suggestions for three files to ignore, I tried adding these to the build.gradle file as per suggestion.



packagingOptions {
exclude 'AndroidManifest.xml'
exclude 'resources.arsc'
exclude 'classes.dex'
}


However this actually means my resources are ignored, and reference to resources in the library result in resource exceptions at runtime.


0 comments:

Post a Comment