Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"
As of Android Studio version 0.8.14
You should add:
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '...'
}
}
to your build.gradle
file.
History:
According to comment 14 in this bug: https://issuetracker.google.com/issues/36982149#comment14 this is a bug in v0.7.0 of the Android Gradle plugin, and is due to be fixed soon in 0.7.1.
Here are the notes from that bug about the addition for 0.7.1:
0.7.1 is out with the fix for this.
The DSL to exclude files is:
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
You can add as many exclude statement as you want. The value is the archive path. No wildcard or glob support yet.
Filenames "LICENSE.txt" and "NOTICE.txt" are case sensitive. Please try out with "license.txt" and "notice.txt" as well.
In my case I had to include several additional exclusions. It appears it doesn't like Regular expressions which would've made this a nice one-liner.
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}