#-------------------------------------------基本不用动区域-------------------------------------------- #---------------------------------基本指令区---------------------------------- -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontskipnonpubliclibraryclassmembers -dontpreverify -verbose -printmapping proguardMapping.txt -optimizations !code/simplification/cast,!field/*,!class/merging/* -keepattributes *Annotation*,InnerClasses -keepattributes Signature -keepattributes SourceFile,LineNumberTable #---------------------------------------------------------------------------- #---------------------------------默认保留区--------------------------------- -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.support.** {*;} -keepclasseswithmembernames class * { native <methods>; } -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 <init>(android.content.Context); public <init>(android.content.Context, android.util.AttributeSet); public <init>(android.content.Context, android.util.AttributeSet, int); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); public <init>(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(); } -keep class **.R$* { *; } -keepclassmembers class * { void *(**On*Event); } #---------------------------------------------------------------------------- #---------------------------------webview------------------------------------ -keepclassmembers class fqcn.of.javascript.interface.for.Webview { public *; } -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, jav.lang.String); } #---------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------- #-------------------------------------------定制化区域---------------------------------------------- #---------------------------------1.实体类--------------------------------- #http entity -dontwarn com.topunion.yibidding.http.biz.** -keep class com.topunion.yibidding.http.biz.**{*;} #bean -dontwarn com.topunion.yibidding.bean.** -keep class com.topunion.yibidding.bean.**{*;} #------------------------------------------------------------------------- #---------------------------------2.第三方包------------------------------- -dontwarn org.codehaus.** -dontwarn java.nio.** -dontwarn java.lang.invoke.** -dontwarn javax.annotation.** #友盟错误SDK #umerror_android_1.0.0.jar -dontwarn umerror_android_1.0.0.jar.** -keep class umerror_android_1.0.0.jar.** { *;} #glide -dontwarn com.bumptech.glide.** -keep class com.bumptech.glide.**{*;} # retrofit2 -dontwarn retrofit2.converter.gson.** -keep class retrofit2.converter.gson.**{*;} # rxjava -dontwarn rx.** -keep class rx.**{*;} # retrofit2.3.0 -dontwarn retrofit2.** -keep class retrofit2.**{*;} #OkHttp -dontwarn okhttp3.** -keep class okhttp3.**{*;} # rxjava -dontwarn retrofit2.adapter.** -keep class retrofit2.adapter.**{*;} #个推 -dontwarn com.igexin.** -keep class com.igexin.**{*;} -keep class org.json.**{*;} -dontwarn com.tencent.** -keep class com.tencent.** { *; } -dontwarn com.tencent.stat.** -keep class com.tencent.stat.** { *; } -dontwarn com.tencent.** -keep class com.tencent.** { *; } -dontwarn com.sina.** -keep class com.sina.** { *; } # glide 的混淆代码 -keep public class * implements com.bumptech.glide.module.GlideModule -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { **[] $VALUES; public *; } # banner 的混淆代码 -keep class com.youth.banner.** { *; } # ButterKnife avoid error -keep class butterknife.** { *; } -dontwarn butterknife.internal.** -keep class **$$ViewBinder { *; } -keepclasseswithmembernames class * { @butterknife.* <fields>; } -keepclasseswithmembernames class * { @butterknife.* <methods>; } #------------------------------------------------------------------------- #---------------------------------3.与js互相调用的类------------------------ -keep class com.topunion.yibidding.utils.WebViewActivity.** { *; } #------------------------------------------------------------------------- #---------------------------------4.反射相关的类和方法----------------------- #---------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
参考文章 :https://www.jianshu.com/p/f3455ecaa56e