为android安装apk版本时出现Proguard错误

时间:2015-11-20 02:08:28

标签: android android-proguard

错误:

  

错误:任务':app:transformClassesAndResourcesWithProguardForRelease'执行失败。   java.io.IOException:无法写[C:\ Users \ user \ Desktop \ ProjetsAndroidStudio \ v_3 \ app \ build \ intermediates \ transforms \ proguard \ release \ jars \ 3 \ 1f \ main.jar](可以& #39;读取[C:\ Users \ user \ Desktop \ ProjetsAndroidStudio \ v_3 \ app \ build \ intermediates \ explosion-aar \ com.google.android.gms \ play-services-analytics \ 8.3.0 \ jars \ classes .jar(;;;;;; ** / * .class)](重复的zip条目[auc.class == classes.jar:com / google / android / gms / analytics / internal / Command $ 1.class]))

proguard-rules.pro:

-dontpreverify
-optimizations !code/simplification/arithmetic
-dontnote
-repackageclasses ''
-allowaccessmodification
-dontskipnonpubliclibraryclasses
-ignorewarnings
-keepattributes *Annotation*,EnclosingMethod
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

-dontskipnonpubliclibraryclassmembers

#Configuration de base Android:
-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.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-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.app.Activity {
public void *(android.view.View);
}

-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

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

-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}

-keepclassmembers class **.R$* {
 public static <fields>;
}

-keepclassmembers enum * {
 public static **[] values();
 public static ** valueOf(java.lang.String);
}

#Pour supprimer les logs lors de la compilation
-assumenosideeffects class android.util.Log {
public static int v(...);
public static int d(...);
public static int i(...);
public static int w(...);
public static int e(...);
public static int wtf(...);
}

#Pour que proguard ignore toutes les classes contenues dans un certain package
#Pour la librairie Jackson (parsing JSON)
-keep class org.codehaus.jackson.** { *; }
-dontwarn org.**


#Pour ActionBarSherlock (d'aprËes le site officiel)
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }

提前致谢!

1 个答案:

答案 0 :(得分:-3)

在面对这个问题时,关闭Minification对我有用:

在build.gradle文件中:

buildTypes {
        release {
            minifyEnabled false