Android混淆配置

Android混淆配置

-------------系统类不需要混淆 --------------------------

-keep public class * extends android.app.Fragment
-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.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.**
-keep public class com.android.vending.licensing.ILicensingService

保持native方法不被混淆

-keepclasseswithmembernames class * {
native ;
}

保留在Activity中的方法参数是view的方法,

这样以来我们在layout中写的onClick就不会被影响

-keepclassmembers class * extends android.app.Activity{
public void *(android.view.View);
}

保留我们自定义控件(继承自View)不被混淆

-keep public class * extends android.view.View{
*** get*();
void set*(***);
public (android.content.Context);
public (android.content.Context, android.util.AttributeSet);
public (android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * { # 保持枚举enum类不被混淆
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable { # 保持Parcelable不被混淆
public static final android.os.Parcelable$Creator *;
}

--------- 忽略异常提示 --------------------

-dontwarn butterknife.internal.**
-dontwarn com.alipay.**
-dontwarn com.mikepenz.**
-dontwarn org.apache.**
-dontwarn com.amap.**
-dontwarn com.android.volley.**
-dontwarn com.rey.**

---------- 保持代码 --------------

-keep class it.neokree.** {;}
-keep class org.apache.** {
;}
-keep class com.iflytek.** {*;}
-keep class com.google.protobuf.** { *; }

保留Parcelable序列化类不被混淆

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

保留Serializable序列化的类不被混淆

-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient ;
!private ;
!private ;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}

你可能感兴趣的:(android)