When trying to build my app using Android Studio 0.8.14, I get the following errors:
Error:duplicate files during packaging of APK C:\Users\pc2_2\Desktop\DOSTTracker\app\build\outputs\apk\app-debug-unaligned.apk
Path in archive: META-INF/LICENSE
Origin 1: C:\Users\pc2_2\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.4.4\e2ff13c3de2f5a2ab2449a3dace2b0d1c37bd8ee\jackson-databind-2.4.4.jar
Origin 2: C:\Users\pc2_2\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.4.4\d3dad1a494f94579fca4b6a1142fb15fb68f0b2f\jackson-annotations-2.4.4.jar
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'META-INF/LICENSE'
}
}
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE
File 1: C:\Users\pc2_2\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.4.4\e2ff13c3de2f5a2ab2449a3dace2b0d1c37bd8ee\jackson-databind-2.4.4.jar
File 2: C:\Users\pc2_2\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.4.4\e2ff13c3de2f5a2ab2449a3dace2b0d1c37bd8ee\jackson-databind-2.4.4.jar
Here is my build.gradle file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.ajwcc.locationtracker"
minSdkVersion 11
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.4'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.4'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'
compile 'org.apache.directory.studio:org.apache.commons.codec:1.8'
}
android {
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'
}
}
I already added the packagingOptions as suggested by Android Studio and other SO posts, but I am still getting the error. What am I missing?
I figured out the problem. I was referencing this app as a dependency from another app, and was building the other app. I had to include the packagingOptions in the build.gradle file of the other app as well.