“重复Zip条目”(来自Proguard) - renderscript-v8.jar

时间:2016-04-21 04:43:04

标签: android-studio gradle android-proguard

我正在Android Studio中开发Android应用程序。当我在没有Proguard的情况下构建导出签名APK的项目时没有问题,但是当我尝试使用ProGuard构建项目时(minifyEnabled为true),有一个Proguard构建失败,错误如下:

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Can't write [user\myapplication\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar] (Can't read [user]sdkpath\SDK\build-tools\23.0.0\renderscript\lib\renderscript-v8.jar(;;;;;;**/*.class)] (Duplicate zip entry [renderscript-v8.jar:android/support/annotation/Keep.class]))

这是我的build.gradle代码

...
    defaultConfig {

        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }
}

dependencies {
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
    compile project(':libraries:gpuimage')
    compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
}

这是我的proguard-rule.pro

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.content.Context {
   public void *(android.view.View);
   public void *(android.view.MenuItem);
}




-keep class *.R
-keep class *.R$* {*;}

-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }

-keep public class * extends android.support.v4.view.ActionProvider {
    public <init>(android.content.Context);
}

## Google AdMob specific rules ##
## https://developers.google.com/admob/android/quick-start ##

-keep public class com.google.ads.** {
     public *;
}

## Google Analytics 3.0 specific rules ##

-keep class com.google.analytics.** { *; }

#-keep class it.sephiroth.** {*;}
-dontwarn it.sephiroth.**

Proguard疑难解答说这个

警告:无法写入资源...重复的zip条目     您的输入jar包含多个具有相同名称的资源文件。 ProGuard像往常一样继续复制资源文件,跳过以前使用过的名称的所有文件。此外,警告可能表示某些问题,因此建议删除重复项。一种方便的方法是在输入罐上指定过滤器。没有选项可以关闭这些警告。

android The standard Android build process automatically specifies the input jars for you. There may not be an easy way to filter them to remove these warnings. You could remove the duplicate resource files manually from the input and the libraries.

但是我没弄明白我在我的构建中添加了两个jar ..!

1 个答案:

答案 0 :(得分:0)

这可能与BuildTools 23.0.0中的renderscript-v8.jar中的错误有关,该错误包含了它自己的注释库副本,并且在与其他支持库一起使用时可能会导致错误。

我建议您尝试使用BuildTools 23.0.3并查看问题是否消失。 23.0.3还包括RenderScript的其他几个修复程序。

相关问题