#移除log代码 -assumenosideeffects classandroid.util.Log { public static *** v(...); public static *** i(...); public static *** d(...); public static *** w(...); public static *** e(...); }
#保持继承自系统类的class不被混淆 -keep public class * extendsandroid.app.Activity -keep public class * extendsandroid.app.Application -keep public class * extendsandroid.app.Service -keep public class * extendsandroid.content.BroadcastReceiver -keep public class * extendsandroid.content.ContentProvider -keep public class * extendsandroid.app.backup.BackupAgentHelper -keep public class * extendsandroid.preference.Preference -keep interface android.support.v4.app.** { *; } -keep classandroid.support.v4.** { *; } -keep public class * extendsandroid.support.v4.** -keep interface android.support.v7.app.** { *; } -keep classandroid.support.v7.** { *; } -keep public class * extendsandroid.support.v7.** -keep public class * extendsandroid.app.Fragment -keep class * extendsandroid.**{*;}
#不混淆Serializable接口的子类中指定的某些成员变量和方法 -keepclassmembers class * implementsjava.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); }
-keepclasseswithmembernames class * { public <init>(android.content.Context); } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet, int); } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet, int, int); }
############ 项目内部类的混淆配置 ############
#不混淆整个包 #-keep class com.test.test.**{*;}
#不混淆对外接口的public类名和成员名,否则外部无法调用 #-keep public interface com.test.test.**{*;} #-keep public enum com.test.test.**{*;} #-keep public class com.test.test.**{ # public *; #}