# (android)在优化阶段移除相关方法的调用 -assumenosideeffects class android.util.Log { public static boolean isLoggable(java.lang.String, int); public static int v(...); public static int i(...); public static int w(...); public static int d(...); public static int e(...); }
# 保留所有的本地 native 方法不被混淆 -keepclasseswithmembernames class * { native <methods>;}
# 保留了继承自 Activity、Application 这些类的子类 # 因为这些子类都有可能被外部调用 # 比如说,第一行就保证了所有Activity的子类不要被混淆 -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.view.View -keep public class com.android.vending.licensing.ILicensingService
-keep class android.os.** {*;}
# 如果有引用 android-support-v4.jar 包,可以添加下面这行 # -keep public class com.tuniu.app.ui.fragment.** {*;}
# 保留在 Activity 中的方法参数是view的方法, # 从而我们在 layout 里面编写 onClick 就不会被影响 -keepclassmembers class * extends android.app.Activity { public void *(android.view.View);}
# 枚举类不能被混淆 -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String);}
# 保留自定义控件(继承自View)不被混淆 -keep public class * extends android.view.View { *** get*(); void set*(***); public <init>(android.content.Context); public <init>(android.content.Context, android.util.AttributeSet); public <init>(android.content.Context, android.util.AttributeSet, int);}
# 保留 Parcelable 序列化的类不被混淆 -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *;}
# 保留 Serializable 序列化的类不被混淆 -keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; !static !transient <fields>; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve();}
# 对于R(资源)下的所有类及其方法,都不能被混淆 -keep class **.R$* {*;}
# Understand the @Keep support annotation. -keep class android.support.annotation.Keep
-keep @android.support.annotation.Keep class * {*;}
-keepclasseswithmembers class * { @android.support.annotation.Keep <methods>; }
-keepclasseswithmembers class * { @android.support.annotation.Keep <fields>; }
-keepclasseswithmembers class * { @android.support.annotation.Keep <init>(...); }
# 对于带有回调函数 onXXEvent 的,不能被混淆 -keepclassmembers class * { void *(**On*Event);} -keepclassmembers class * { public void onEvent*(**); }
# 保留实体类和成员不被混淆 #-keep public class com.youndheart.entity.** { # public void set*(***); # public *** get*(); # public *** is*();} # 干脆这样写 -keep public class com.zejian.android4package.model.**{*;}
# 不混淆内嵌类 -keep class com.example.youngheart.MainActivity$*{*;}
# 对WebView的处理 -keepclassmembers class * extends android.webkit.webViewClient { public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap); public boolean *(android.webkit.WebView, java.lang.String);}
-keepclassmembers class * extends android.webkit.webViewClient { public void *(android.webkit.webView, java.lang.String);}
-keepclassmembers class * extends android.webkit.WebChromeClient { public void *(android.webkit.WebView, java.lang.String); }
# 对JavaScript的处理 # 请在项目中搜索 addJavascriptInterface,我们要对所有使用的地方设置保留指令。 -keepclassmembers class com.example.youngheart.MainActivity$JSInterface1 { <methods>;}