0
votes

Errors log are below:

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: C:\Users\MYPC.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpmime\4.5\7bdb321e86724b16af6134a0fd22fec649eda971\httpmime-4.5.jar File2: C:\Users\MYPC.gradle\caches\modules-2\files-2.1\xerces\xercesImpl\2.11.0\9bb329db1cfc4e22462c9d6b43a8432f5850e92c\xercesImpl-2.11.0.jar File3: C:\Users\MYPC.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.6.0\a0990e2e812ac6639b6ce955c91b13228500476e\jackson-annotations-2.6.0.jar

Dependencies I'm using below:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    useLibrary  'org.apache.http.legacy'

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

    testOptions {
        unitTests.returnDefaultValues = true
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'

    }

}



     dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:24.2.0'
        compile 'junit:junit:4.12'
        compile 'io.appium:java-client:3.3.0'
        compile 'com.googlecode.json-simple:json-simple:1.1.1'
        compile 'commons-lang:commons-lang:2.6'
        compile 'com.google.code.gson:gson:2.5'
        compile 'com.testdroid:testdroid-api:2.9'
        testCompile 'org.mockito:mockito-core:1.10.19'

        compile 'com.google.dagger:dagger:2.4'
        annotationProcessor 'com.google.dagger:dagger-compiler:2.4'

        configurations {
            all*.exclude group: 'commons-logging', module: 'commons-logging'
        }

    }

How I can remove this error ?

1
First you need to check which library have duplicate files in jar or library. and thn you can exclude the files or library. to check duplicate library please check how to find dependency and hierarchy stackoverflow.com/a/35571144/1140237user1140237
you can also check this for dependency stackoverflow.com/a/35572543/1140237user1140237

1 Answers

1
votes

You should add this in your build.gradle section

META-INF directory are recognized and interpreted by the Java 2 Platform to configure applications, extensions;

 packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'

}

Then Clean-Rebuild-Run