Android Studio - ProGuard IOException Duplicate Zi

2019-04-08 17:03发布

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>;
}

1条回答
不美不萌又怎样
2楼-- · 2019-04-08 17:32

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'
}
查看更多
登录 后发表回答