指定代码的压缩级别
-optimizationpasses 5
是否使用大小写混合
-dontusemixedcaseclassnames
是否混淆第三方jar
-dontskipnonpubliclibraryclasses
混淆时是否做预校验
-dontpreverify
混淆时是否记录日志
-verbose
基本配置-不能被混淆的
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Fragment
-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.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
support.v4/v7包不混淆
-keep class android.support.* { ; }
-keep class android.support.v4.* { ; }
-keep public class * extends android.support.v4.**
-keep interface android.support.v4.app.* { ; }
-keep class android.support.v7.* { ; }
-keep public class * extends android.support.v7.**
-keep interface android.support.v7.app.* { ; }
-dontwarn android.support.** # 忽略警告
保持注解继承类不混淆
-keep class * extends java.lang.annotation.Annotation {*;}
保持Serializable实现类不被混淆
-keepnames class * implements java.io.Serializable
保持枚举enum类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
自定义组件不被混淆
-keep public class * extends android.view.View {
public (android.content.Context);
public (android.content.Context, android.util.AttributeSet);
public (android.content.Context, android.util.AttributeSet, int);
public void set*(…);
}
不混淆资源类
-keepclassmembers class *.R$ {
public static ;
}
保持 native 方法不被混淆
-keepclassmembers class * extends android.app.Activity { # 保持自定义控件类不被混淆
public void *(android.view.View);
}