1
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: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar
    File2: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar
    File3: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar

I have tried using

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

and this works but I don't want to exclude the licence please tell how I can avoid it with out using this

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
         release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:design:24.2.1'

    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.firebase:firebase-storage:9.4.0'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    compile 'com.google.firebase:firebase-auth:9.4.0'
    compile 'com.firebase:firebase-client-android:2.5.2'

    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}

here is my gradle which has many dependencies so please let me know which dependencies are causing the issue

AL.
  • 36,815
  • 10
  • 142
  • 281
Ashish
  • 61
  • 8

3 Answers3

1

Edit: If you want to go with the defined dependencies. You need to use the below code:

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

Otherwise you need to remove the used dependencies as they have conflicts in files.

Android Geek
  • 8,956
  • 2
  • 21
  • 35
  • It one and the same thing i dont want to exclude the license that why i posted it with my current solution which i am not looking for. Thanks anyways – Ashish Sep 21 '16 at 05:35
  • Ok then you need to change the dependencies, as depedencies are getting conflicts in License.txt files. – Android Geek Sep 21 '16 at 05:40
  • But can you please help me out which dependencies are causing the issues that will be a great help. – Ashish Sep 21 '16 at 06:14
  • Dependencies related to firebase, and if you require al of them you need to use the above code. – Android Geek Sep 21 '16 at 06:40
1

You're mixing versions of the Firebase client, which is guaranteed to give you more problems down the line.

Use a single version for all your Firebase dependencies, such as 9.4.0:

compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0' // this one changed
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
0

packagingOptions { pickFirst 'META-INF/LICENSE' }

I tried this and its working great please try it.

Ashish
  • 61
  • 8
  • That accomplishes the same as @AndroidGeek's answer. But don't mix versions of the various features in the Firebase SDK. It's a recipe for problems. – Frank van Puffelen Sep 21 '16 at 13:23
  • I agree completely because i found the prob it was a issue with gsm service. Thanks for the help appreciated – Ashish Sep 28 '16 at 05:20