13

I've been using the Gradle Android plugin v0.12 but I decided to upgrade to the new version, because I needed the new functionality (and the improved speed is always a plus).

After updating to the new v0.13.1, I keep getting the "Duplicate Zip Entry" (from Proguard) while everything worked before. The full error:

java.io.IOException: Can't write [/Users/.../classes-proguard/netherlands/release/classes.jar] (Can't read [/Users/.../.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class])) (CopyUtils was FileUtils before).

I'm using following packaging options: packagingOptions

{ 
   exclude 'AndroidManifest.xml' 
   exclude 'META-INF/DEPENDENCIES' 
   exclude 'META-INF/notice.txt' 
   exclude 'META-INF/license.txt' 
   exclude 'META-INF/LICENSE.txt' 
   exclude 'META-INF/NOTICE.txt' 
   exclude 'META-INF/MANIFEST.MF' 
   exclude '!META-INF/MANIFEST.MF' 
   exclude 'META-INF/services/javax.annotation.processing.Processor' 
}

As you can tell, I'm excluding the manifest files...

Just to test it, I changed back to version 0.12.0 and everything works again, back to 0.13.* and it breaks (but I need 0.13.*)!

Further, I'm using the following libraries:

  1. Robospice
  2. Retrofit
  3. OkHttp
  4. Dart
  5. Icepick
  6. Butterknife
  7. Crouton
  8. SmoothProgressBar
  9. NineoldsAndroid (in library of BetterPickers)

Did anyone encounter this issue too? If so, can anyone please help me out (been breaking my head for 2 days on this issue now!)? Thanks!

Opal
  • 81,889
  • 28
  • 189
  • 210
Superplastik
  • 133
  • 1
  • 1
  • 4
  • Looks like you are not the only one: https://github.com/stephanenicolas/robospice/issues/365 – rciovati Sep 26 '14 at 15:15
  • Does it work if you delete the .gradle folder in your home directory and rebuild? How about if you clean your project and rebuild? – Scott Barta Sep 26 '14 at 19:25
  • I tried deleting the Gradle cache, .gradle folder, ... Nothing worked, the answer by Gaëten did however! Seems to be an error in the build tools! – Superplastik Sep 29 '14 at 06:28
  • You need to run `./gradlew -q app:dependencies`, and see what are your duplicate dependencies eligible for exclusion. – IgorGanapolsky Oct 25 '17 at 13:30

4 Answers4

15

I had the same issue when updating to Android Gradle plugin 0.13. I managed to fix it by including retrofit this way in my build.gradle file:

compile('com.squareup.retrofit:retrofit:1.6.1') {
    exclude group: 'commons-io', module: 'commons-io'
}

Edit: And can do this on all retrofit and robospice dependcies at once with:

compile('com.octo.android.robospice:robospice-retrofit:1.4.14') {
    exclude group: 'commons-io', module: 'commons-io'
}

It will get all underlying dependencies automatically (retrofit, robospice-core, robospice-cache, ...).

Gaëtan
  • 11,912
  • 7
  • 35
  • 45
  • 1
    Partly solved it! I'll give you the answer though. Real solution was to apply the exclude group on: retrofit AND all robospice parts (robospice core, cache and retrofit plugin). Thank you very much! I own you a coffee! – Superplastik Sep 27 '14 at 17:09
  • Thanks for the coffee :p You can do this with only one dependecy. See the second part in my answer. – Gaëtan Sep 29 '14 at 05:34
  • I still had to define all 'exclude groups' or gradle refused to work! – Superplastik Sep 29 '14 at 06:42
  • This works, indeed, but I think the root cause is a bug in the build system. With a proper fix in Gradle plugin for Android those workarounds shouldn't be necessary, this should just work. Problem is I had a problem reproducing this on a mock project, so it is hard to push a ticket to Googles Gradle Android plugin team. – Maciej Pigulski Sep 29 '14 at 07:32
15

I had the same issue. In my case I hadn't done a build for a few months, and found that the dependency compile 'org.apache.commons:commons-io:1.3.2' is no longer valid (though I guess the jars were still in my local repository).

Once I changed it to compile 'commons-io:commons-io:1.3.2', proGuard ran fine.

CjS
  • 2,037
  • 2
  • 21
  • 29
  • This is the only fix that worked for me. Gaetlan's didn't resolve the issue. – drc Nov 05 '14 at 17:19
  • Same situation, same fix. Do not understand. – Jacob Tabak Dec 21 '14 at 20:16
  • Source: [This artifact was moved](https://mvnrepository.com/artifact/org.apache.commons/commons-io). Thanks for pointing me in the right direction! Turns out there is also a new version, as of this writing the lib is on 2.5 – yuval Dec 30 '16 at 01:50
  • @ CJS, please how did you "change it " to compile 'commons-io:commons-io:1.3.2' ? – S bruce Mar 24 '17 at 03:05
1

By Using CjS answer I was able to solve this. Even Gaetan Answer is also works.

Adding to this I solved the Issue by Using This, if your compileSdkVersion is 19(IN MY CASE)

compile ('org.apache.httpcomponents:httpmime:4.3'){
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile ('org.apache.httpcomponents:httpcore:4.4.1'){
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile 'commons-io:commons-io:1.3.2'

else if your compileSdkVersion is 23 then use

android {
useLibrary 'org.apache.http.legacy'
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    }
}
Sophia
  • 1,046
  • 1
  • 12
  • 15
-4

The problem is in libs that you're using.

Add in gradle file:

android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/MANIFEST.MF'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
QArea
  • 4,955
  • 1
  • 12
  • 22