2016-04-21 52 views
0

我正在Android Studio中開發Android應用程序。有沒有問題,當我建立一個出口簽署APK沒有Proguard的項目,但是當我嘗試建立使用ProGuard(minifyEnabled真)的項目中,有一個Proguard的構建失敗,錯誤是這樣的:「重複郵編條目」(來自Proguard) - renderscript-v8.jar

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. 

但我沒有想出哪個罐子我在我的建立兩次添加..!

回答

0

這可能與BuildTools 23.0.0中的renderscript-v8.jar中的一個錯誤有關,該錯誤包括它自己的註釋庫副本,並可能在與其他支持庫一起使用時導致錯誤。

我建議你嘗試使用BuildTools 23.0.3,看看問題是否消失。 23.0.3還包含RenderScript的其他幾個修補程序。

相關問題