Stuart Stuart - 2 months ago 15
Android Question

Duplication of files during application build (post gradle update)

Since updating Android Studio and gradle, debug and normal builds give me duplication errors:

: duplicate files during packaging of APK /Users/Stu/projects/****/build/apk/*****-debug-unaligned.apk

Execution failed for task ':*****:packageDebug'.



Duplicate files copied in APK META-INF/ASL2.0
File 1: /Users/Stu/.gradle/caches/modules-2/files-2.1/org.codehaus.jackson/jackson-mapper-asl/1.9.11/45d70862fa016993193075a1e8e32a01dcf438e8/jackson-mapper-asl-1.9.11.jar
File 2: /Users/Stu/.gradle/caches/modules-2/files-2.1/org.codehaus.jackson/jackson-mapper-asl/1.9.11/45d70862fa016993193075a1e8e32a01dcf438e8/jackson-mapper-asl-1.9.11.jar


I've added the recommended fix to the build.gradle (Duplicate files copied (Android Studio 0.4.0)):

buildscript {
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
url 'http://dl.bintray.com/populov/maven'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.+'
}
}
apply plugin: 'android'
apply plugin: 'android-test'

configurations {
unitTestCompile.extendsFrom runtime
unitTestRuntime.extendsFrom unitTestCompile
}


repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
url 'http://dl.bintray.com/populov/maven'
}
mavenCentral()
}

android {
compileSdkVersion 19
buildToolsVersion "19.0.0"

defaultConfig {
minSdkVersion 17
targetSdkVersion 19
}

sourceSets {
instrumentTest.setRoot('src/test')
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}

dependencies {
compile ('com.octo.android.robospice:robospice-spring-android:1.4.7')
{
exclude module: 'support-v4'
}
compile 'org.codehaus.jackson:jackson-mapper-asl:1.+'
compile 'com.android.support:appcompat-v7:+'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'com.google.android.gms:play-services:4.0.30'
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.+'
testCompile 'com.squareup:fest-android:1.0.+'
instrumentTestCompile 'junit:junit:4.10'
instrumentTestCompile 'org.robolectric:robolectric:2.+'
instrumentTestCompile 'com.squareup:fest-android:1.0.+'
}

Answer

It looks like the META-INF/ASL2.0 file is being duplicated. Try adding this to your packagingOptions:

exclude 'META-INF/ASL2.0'`