0

I am making an android app where I am using these libraries:

compile "org.apache.httpcomponents:httpcore:4.4.4"
compile "org.apache.httpcomponents:httpmime:4.4.1"

but it is giving an error:

com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/org.apache.httpcomponents/httpmime/pom.xml File1: C:\Users\Vivek\projectX\app\libs\httpmime-4.4.1.jar File2: C:\Users\Vivek.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpmime\4.4.1\2f8757f5ac5e38f46c794e5229d1f3c522e9b1df\httpmime-4.4.1.jar

So I searched and found a solution using:

packagingOptions {
    exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
    exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
}  

But it is again showing the same error. Does anybody know what am I doing wrong? Thank you.

f-CJ
  • 4,235
  • 2
  • 30
  • 28
Nicky Manali
  • 386
  • 3
  • 22
  • http://stackoverflow.com/questions/20827885/android-studio-0-4-duplicate-files-copied-in-apk-meta-inf-license-txt – IntelliJ Amiya Nov 16 '16 at 06:39
  • add `compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1' compile 'org.apache.httpcomponents:httpmime:4.3.5'` – IntelliJ Amiya Nov 16 '16 at 06:40
  • i used it earlier and it doesn't work. – Nicky Manali Nov 16 '16 at 06:44
  • http://stackoverflow.com/a/36978570/5545429 – shinilms Nov 16 '16 at 06:55
  • it is giving me a warning like In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android. – Nicky Manali Nov 16 '16 at 07:03

1 Answers1

0

Try to add below packagingOptions in your build.gradle.

 packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'httpcore-4.4.4'
    exclude 'httpmime-4.4.1'
}

If you have same issue you can try to add packagingOption like that

  exclude 'META-INF/maven/org.apache.httpcomponents/httpmime/pom.xml'

For more information refer link refer Link

Community
  • 1
  • 1
Nitin Karande
  • 1,280
  • 14
  • 33
  • In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android. – Nicky Manali Nov 16 '16 at 07:03