1

I just updated Android Studio and I cannot build my app after doing so. I receive an exception looking like this:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
    File1: /Users/andersvincentlund/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.2.2/d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b/jackson-core-2.2.2.jar
    File2: /Users/andersvincentlund/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.2.2/3c8f6018eaa72d43b261181e801e6f8676c16ef6/jackson-databind-2.2.2.jar
    File3: /Users/andersvincentlund/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.2.2/285cb9c666f0f0f3dd8a1be04e1f457eb7b15113/jackson-annotations-2.2.2.jar

I have googled this type of error and have been suggested to add:

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

in the android clause in gradle. This changes nothing(except makes my build potentially illegal since I would be ignoring licensing for OS code?). Does anyone have an idea on how to solve this? I was hoping an update would not break the code.

EDIT:

I got a comment regarding gradle file so I am posting the entire thing below:

apply plugin: 'com.android.application'
    

apply plugin: 'com.neenbedankt.android-apt'
    

apply plugin: 'com.android.application'

apply plugin: 'com.neenbedankt.android-apt'


android {
    packagingOptions {
        exclude 'META-INF/NOTICE' // will not include NOTICE file
        exclude 'META-INF/LICENSE' // will not include LICENSE file
        exclude 'META-INF/notice'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license'
        exclude 'META-INF/license.txt'
    }
    signingConfigs {
        config {
            keyPassword 'XXXXX'
            storeFile file('/XXXXX/XXXXX/XXXXX/android.keystore')
            storePassword 'XXXXX'
            keyAlias 'XXXXX'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "XXXXX"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.config
        }
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }


}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.9.5'
    apt 'com.google.dagger:dagger-compiler:2.5'
    provided 'javax.annotation:jsr250-api:1.0'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    compile 'com.google.dagger:dagger:2.5'
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.firebase:firebase-database:9.4.0'
    compile 'com.google.firebase:firebase-auth:9.4.0'
    compile 'com.firebaseui:firebase-ui:0.3.1'
    compile 'com.firebase:firebase-client-android:2.4.0'
    compile group: 'com.google.guava', name: 'guava', version: '19.0'
}
apply plugin: 'com.google.gms.google-services'
why_vincent
  • 2,172
  • 9
  • 33
  • 49
  • Possible duplicate of [Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'](http://stackoverflow.com/questions/34031395/errorexecution-failed-for-task-apptransformresourceswithmergejavaresfordebug) – Jordan Oct 10 '16 at 11:27
  • Provided the solution that I mention above, that doesn't solve my issue. – why_vincent Oct 10 '16 at 11:35
  • You also need to make sure you have not added any libraries twice – Jordan Oct 10 '16 at 11:40
  • I'm kind of new when it comes to gradle but I figure that these should work just fine together no? I updated the question with the dependencies. – why_vincent Oct 10 '16 at 11:42
  • Please post complete gradle file code in the question – Jordan Oct 10 '16 at 11:43
  • Added the entire file. SO refuses to format first two lines as code, sorry about that. – why_vincent Oct 10 '16 at 11:54

2 Answers2

2

Just Remove:

compile fileTree(include: ['*.jar'], dir: 'libs')

from

dependencies {}

The jackson-core-2.2.2.jaris already present in your libs/ but another dependency is trying to add it again externally.

Jordan
  • 713
  • 15
  • 30
-1

Please add below line

packagingOptions {
exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.xml'
exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.properties'}
Arti
  • 672
  • 7
  • 19