问题描述
因此,我尝试在 Gradle 中为我的 Android Studio 项目设置 ProGuard,但在构建项目时出现以下错误:
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:
错误:任务:app:proguardDebug"的执行失败.java.io.IOException: 无法写入 [C:\Users\Rich\Desktop\WebProjects\AndroidStudioProjects\Roomie\app\build\intermediates\classes-proguard\debug\classes.jar](无法读取 C:\Users\Rich\Desktop\WebProjects\AndroidStudioProjects\Roomie\app\libs\bolts-android-1.1.4.jar(;;;;;;!META-INF/MANIFEST.MF)](重复的 zip 条目 [a/a.class == bolts-android-1.1.4.jar:bolts/AggregateException.class]))
这是我的 proguard-rules.pro
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>;
}
推荐答案
供以后参考:
我偶然发现了同样的问题,这个帖子帮助我解决了这个问题.
I stumbled upon the same problem and this post on SO helped me solved it.
基本上,当您在项目中包含库时,其中一些库包含常见的依赖项,这就是 proguard 因 IOException 而失败的原因.
Basically when you include libraries in your project, some of them contain common dependencies and this is why proguard fails with an IOException.
我的问题是我使用了 Parse 和 Facebook SDK,并且它们都导入了 bolts 库作为依赖项.
在导入冲突的 SDK 之一时,只需添加一些 exclude 指令即可解决问题:
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'
}
这篇关于Android Studio - ProGuard IOException Duplicate Zip Entry的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!