Home » Android » gradle – Duplicate files copied (Android Studio 0.4.0)

gradle – Duplicate files copied (Android Studio 0.4.0)

Posted by: admin March 11, 2020 Leave a comment

Questions:

In my project I use httpcore and httpmime libraries from Apache. After update Android Studio to 0.4.0 I have this issue building my project:

Duplicate files copied in APK META-INF/DEPENDENCIES
File 1: /home/slava/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.1/f7899276dddd01d8a42ecfe27e7031fcf9824422/httpmime-4.3.1.jar
File 2: /home/slava/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.1/f7899276dddd01d8a42ecfe27e7031fcf9824422/httpmime-4.3.1.jar

Here is stacktrace of Gradle build:

The build.gradle looks like this:

Edit 1:
Managed to solve this problem deleting files I had problem with from the local copy of httpmime library in META-INF directory

How to&Answers:

According to comment 14 in this bug: https://code.google.com/p/android/issues/detail?id=61573#c14 this is a bug in v0.7.0 of the Android Gradle plugin, and is due to be fixed soon in 0.7.1.

EDIT

Here are the notes from that bug about the addition for 0.7.1:

0.7.1 is out with the fix for this.

The DSL to exclude files is:

You can add as many exclude statement as you want. The value is the archive path. No wildcard or glob support yet.

Answer:

Follow the advice Gradle gives you at the end of the build. In my case it told me to add: