0

I am working on a project for a client. The project seems to work fine in the old Android Studio, but ever since I updated my studio to 2.2.2, I am getting the sync error when trying to run the app, the error message is as posted 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: /home/empressum/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient-android/4.3.5.1/eecbb0b998e77629862a13d957d552b3be58fc4e/httpclient-android-4.3.5.1.jar
         File2: /home/empressum/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3/5b0002c5fb66867ca919be0fbd86de1cfaf76da7/httpmime-4.3.jar
mad_greasemonkey
  • 864
  • 2
  • 15
  • 32

5 Answers5

0

Add following into respective build.gradle file

  android {
 packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/MANIFEST.MF'
}
}
Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77
0

You might also want to check if you have 2 references of the same library or .jar included and remove the duplicate reference.

zapping
  • 4,118
  • 6
  • 38
  • 56
0

Guess you are using dependency which is conflicting with androids supplied jars. Add

compile('org.apache.httpcomponents:httpmime:4.3.6') {

   exclude module: 'httpclient'
   exclude group: 'org.apache.httpcomponents', module: 'httpclient'

}

in your gradle.

Community
  • 1
  • 1
Ajay_Arya
  • 1
  • 4
0

You are using two many libraries files for http call instead use jar file on libs or add some dependency in gradle.

0

The error went when I downloaded the project zip file again and run it. But this time when Android Studio asked me to update the gradle file, I denied. I dont know if this explains the error, but now the project is running fine on any device I connect.

mad_greasemonkey
  • 864
  • 2
  • 15
  • 32