android混淆

# 压缩质量  0~7
-optimizationpasses 5

#不采用大小写命名的混淆
-dontusemixedcaseclassnames

#不跳过类库例的非公共类
-dontskipnonpubliclibraryclasses

#混淆时是否记录日志(混淆后生产映射文件 map 类名 -> 转化后类名的映射
-verbose

#不跳过类库中的非公共方法
-dontskipnonpubliclibraryclassmembers

# 不做预校验
-dontpreverify

# 不混淆注解和内部类
-keepattributes *Annotation*,InnerClasses

#保持泛型
-keepattributes Signature

#保持源文件以及行号
-keepattributes SourceFile,LineNumberTable

# 混淆算法
-optimizations !code/simplification/cast,!field/*,!class/merging/*


#############################################
#
# Android开发中一些需要保留的公共部分
#
#############################################

 ## 注册等需要类名,所以不能被混淆
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Appliction
-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.view.View
-keep public class com.android.vending.licensing.ILicensingService

-keep class **.R$* {*;}

-keepclasseswithmembernames class * {
    native ;
}
-keepclassmembers class * extends android.app.Activity{
    public void *(android.view.View);
}
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-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);
}

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

# 同上
-keepclassmembers class * implements java.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();
}

#触摸事件
-keepclassmembers class * {
    void *(**On*Event);
}

你可能感兴趣的:(android混淆)