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.
Error : Gradle: Duplicate files during packaging of APK
Add below lines in the packagingOptions and dependencies.
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
And in dependencies use as below.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile('org.springframework.android:spring-android-auth:1.0.1.RELEASE') {
exclude module: 'spring-core'
}
compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'joda-time:joda-time:2.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.2'
compile 'com.google.code.gson:gson:2.6.2'
}
I think this will solve your issues.
Why this error happen Duplicate files during packaging of APK?How to fix this error?
Replace your gradle with this
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "your_package_name"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENCE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
<!--Jar's Goes Here-->
}
Still getting the error means replace packagingOptions
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
Error :: duplicate files during packaging of APK
I think the string comparison is case sensitive. try with exclude 'META-INF/notice.txt'
duplicate files during packaging
Just add packagingOptions { exclude 'builddef.lst' }
to your gradle file - it should be enough.
Full version:
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "*******"
minSdkVersion 19
targetSdkVersion 26
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 'builddef.lst'
}
}
Related Topics
Save Arraylist to Sharedpreferences
How to Send an Object from One Android Activity to Another Using Intents
How to Load an Imageview by Url in Android
How to Access My Localhost from My Android Device
How to Connect to Android With Adb Over Tcp
Auto Scale Textview Text to Fit Within Bounds
How to Start New Activity on Button Click
Programmatically Obtain the Phone Number of the Android Phone
Checking If an Android Application Is Running in the Background
How to Retrieve Data from Firebase to My Adapter
Android Studio Suddenly Cannot Resolve Symbols
How to Display a Toast from a Background Thread on Android
Integrating the Zxing Library Directly into My Android Application
How to Put Google Maps V2 on a Fragment Using Viewpager
How to Completely Uninstall Android Studio from Windows(V10)