0

I am developing android application in Android Studio. There is no problem when I build the project an export signed APK without Proguard, but when I try to build the project with ProGuard(minifyEnabled true), there is an Proguard build failed with error like this:

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]))

Here is my build.gradle codes

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

Here is my 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 Troubleshooting Say this

Warning: can't write resource ... Duplicate zip entry Your input jars contain multiple resource files with the same name. ProGuard continues copying the resource files as usual, skipping any files with previously used names. Once more, the warning may be an indication of some problem though, so it's advisable to remove the duplicates. A convenient way to do so is by specifying filters on the input jars. There is no option to switch off these warnings.

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.

But i didn't figured out the which jar i added twice in my build..!

Hardik Kubavat
  • 251
  • 3
  • 23

1 Answers1

0

This might be related to a bug in renderscript-v8.jar in BuildTools 23.0.0, which included it's own copy of the annotation library and might cause error when used with some other support library.

I would suggest you try use BuildTools 23.0.3 and see if the problem goes away. 23.0.3 also included several other fixes for RenderScript.

Miao Wang
  • 1,120
  • 9
  • 12