Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - ProGuard IOException Duplicate Zip Entry

So I am trying to set up ProGuard in Gradle for my Android Studio project and I get the following error when building the project:

Error:Execution failed for task ':app:proguardDebug'. java.io.IOException: Can't write [C:\Users\Rich\Desktop\WebProjects\AndroidStudioProjects\Roomie\app\build\intermediates\classes-proguard\debug\classes.jar] (Can't read C:\Users\Rich\Desktop\WebProjects\AndroidStudioProjects\Roomie\app\libs\bolts-android-1.1.4.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [a/a.class == bolts-android-1.1.4.jar:bolts/AggregateException.class]))

Here is my proguard-rules.pro

-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }

-dontwarn org.apache.http.annotation.**

-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}
like image 753
Rich Luick Avatar asked May 23 '15 22:05

Rich Luick


1 Answers

For futur reference :

I stumbled upon the same problem and this post on SO helped me solved it.

Basically when you include libraries in your project, some of them contain common dependencies and this is why proguard fails with an IOException.

My problem was that I used Parse and Facebook SDKs and both of them imported bolts library as a dependency.
Simply adding some exclude directives when importing one of the conflicting SDKs solved the problem :

compile ('com.facebook.android:facebook-android-sdk:4.4.0') {
    exclude module: 'bolts-android'
    exclude module: 'support-v4'
}
like image 153
Greg Avatar answered Sep 27 '22 18:09

Greg