Reputation: 386
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.
Upvotes: 0
Views: 368
Reputation: 1325
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
Upvotes: 0