2
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithJarMergingForDebug UP-TO-DATE
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:transformClassesWithMultidexlistForDebug UP-TO-DATE
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug FAILED


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.txt   File1: C:\Users\system2\AndroidStudioProjects\PorjectName\app\libs\spring-android-rest-template-2.0.0.M1.jar    File2: C:\Users\system2\AndroidStudioProjects\ProjectName\app\libs\spring-android-core-2.0.0.M1.jar
Abhinav singh
  • 1,448
  • 1
  • 14
  • 31
Jossy Joy
  • 35
  • 1
  • 1
  • 5
  • Please add your `build.gradle` file ..!! – AndiGeeky Nov 24 '15 at 08:26
  • Possible duplicate of ["Duplicate lib file copied in APK-META-INF/license.txt "error in andorid studio](http://stackoverflow.com/questions/31912459/duplicate-lib-file-copied-in-apk-meta-inf-license-txt-error-in-andorid-studio) – fasteque Nov 24 '15 at 08:38

4 Answers4

14

This question is duplicate. For resolve it you must add

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

in build.gradle

Faezeh
  • 161
  • 1
  • 5
11

I faced the same problem and I adopted the above mentioned logic ie. adding

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

in build.gradle ... But it didn't work for me and I added the following code that eventually worked... Adding the following code in build.gradle

       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'
       }
Rabin Pantha
  • 941
  • 9
  • 19
  • I was stuck in same problem and thinking same as of you and your answers give me confidence .. thanks – Jishant Aug 12 '16 at 12:59
4

I also faced this same problem. Some files have the ".txt" and some do not. If you keep adding one exclude at a time and run your app, you will see in the "Messages Gradle Build" window all the files needed to exclude in your project. All I needed was this code and it solved my problem.

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
}
ChrisR
  • 607
  • 6
  • 16
2

I faced the same issue. I added this code:

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

inside my build.gradle Module:app into the section android{}

At the end, my adroid section on build.gradle. Module app is:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        // Enabling multidex support.
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE-FIREBASE.txt'
            exclude 'META-INF/NOTICE'
        }

}
Juan Pablo
  • 1,213
  • 10
  • 15