# Optimization is turned off by default. Dex does not like code run # through the ProGuard optimize and preverify steps (and performs some # of these optimizations on its own). # 不优化输入的类文件 -dontoptimize # 混淆时是否做预校验 -dontpreverify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguard-android-optimize.txt" file instead of this one from your # project.properties file. # 保护注解 -keepattributes *Annotation* # 保持哪些类不被混淆 -keep public classcom.google.vending.licensing.ILicensingService -keep public classcom.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native # 保持 native 方法不被混淆 -keepclasseswithmembernames class * { native <methods>; }
# keep setters in Views so that animations can still work. # see http://proguard.sourceforge.net/manual/examples.html#beans # 保持指定类的成员 这里是保持 View中的get set方法不被混淆 -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); }
# 保持Activity中onClick使用到的方法 # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); }
# 保持枚举 enum 类不被混淆 # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); }
# 保持 Parcelable 不被混淆 -keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator CREATOR; } # 保持静态类不被混淆 -keepclassmembers class **.R$* { public static <fields>; }
# The support library contains references to newer platform versions. # Don't warn about those in case this app is linking against an older # platform version. We know about them, and they are safe. -dontwarn android.support.**