我在proguard优化方面遇到了一些问题。
我有以下build.gradle片段。
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
以及相应的proguard-rules.pro。
-dontskipnonpubliclibraryclasses
-dontobfuscate
-forceprocessing
-optimizationpasses 5
-optimizations !class/unboxing/enum
-keep class * extends android.app.Activity
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
public static *** wtf(...);
}
-keep public class com.google.android.gms.ads.** {
public *;
}
-keep public class com.google.android.gms.maps.** {
public *;
}
-keep public class com.google.ads.** {public *;}
-keep public class com.google.android.gms.* { public *; }
-keep public class com.google.android.gms.ads.* { public *; }
-dontwarn com.google.android.gms.**
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
如果使用proguard-android.txt而不是proguard-android-optimize.txt,则没有问题 要修改proguard-rules.pro,我已添加了可以找到的任何修改。 但是以下错误不断发生。 请帮忙。谢谢。
:app:dexTrialRelease
EXCEPTION FROM SIMULATION:
local variable type mismatch: attempt to set or access a value of type java.lang.Object using a local variable of type int. This is symptomatic of .class transformation tools that ignore local variable information.
...at bytecode offset 000000e6
locals[0000]: Lcom/google/android/gms/maps/model/internal/zzf$zza;
locals[0001]: I
locals[0002]: Landroid/os/Parcel;
locals[0003]: Landroid/os/Parcel;
locals[0004]: I
stack[top0]: Ljava/lang/String;
...while working on block 00e6
...while working on method onTransact:(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z
...while processing onTransact (ILandroid/os/Parcel;Landroid/os/Parcel;I)Z
...while processing com/google/android/gms/maps/model/internal/zzf$zza.class
1 error; aborting