Android Studio - ProGuard IOException Duplicate Zip Entry

匿名 (未验证) 提交于 2019-12-03 03:10: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:

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


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!