# Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile # ------ 通用配置 ------ -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify #-dontobfuscate #-dontoptimize -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* # ------ 官方模板推荐不需要混淆的组件 ------ -keep public class * extends android.app.Application -keep public class * extends android.app.Activity -keep public class * extends android.app.Service -keep public class * extends android.content.ContentProvider -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -keep public class * extends android.widget.PopupWindow -keep public class * extends androidx.fragment.app.Fragment -keep class * extends android.webkit.WebChromeClient {*;} -keep class * extends android.webkit.WebViewClient {*;} -keep public class com.android.vending.licensing.ILicensingService # 忽略自定义控件 -keep public class * extends android.view.View { public (android.content.Context); public (android.content.Context, android.util.AttributeSet); public (android.content.Context, android.util.AttributeSet, int); public void set*(...); *** get*(); } -keepclassmembers class * extends android.app.Activity{ public void *(android.view.View); } ## 禁止混淆枚举类型 -keepclassmembers,allowoptimization enum * { public static **[] values(); public static ** valueOf(java.lang.String); } # 忽略原生方法 -keepclasseswithmembernames class * { native ; } # 忽略枚举 -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } # 忽略序列化实体类 -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } -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 void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); } # 保留Annotation不混淆 -keepattributes *Annotation*,InnerClasses # 避免混淆泛型 -keepattributes Signature -keepattributes SourceFile,LineNumberTable -keepattributes EnclosingMethod # 保持R文件不被混淆 -keep public class **.R$* {*;} # ------ 应用定制混淆方案 ------ -keep class **.*$JavaScriptInterface{*;} -keepclassmembers class * { public (org.json.JSONObject); } -keep class beer.toktok.common.activity.**{*;} -keep class beer.toktok.common.fragment.**{*;} -keep class beer.toktok.common.adapter.**{*;} -keep class beer.toktok.common.dialog.**{*;} -keep class beer.toktok.**.model.**{*;} -keep class beer.toktok.**.vo.**{*;} -keep class beer.toktok.**.event.**{*;} -keep class beer.toktok.**.open.**{*;} -keep public class * extends androidx.** -dontwarn androidx.** # Gson -keep class com.google.gson.** {*;} -dontwarn com.google.gson.** -keep class org.json.** {*;} -dontwarn sun.misc.** -keep class sun.misc.Unsafe { *; } -keep class * extends com.google.gson.TypeAdapter -keep class * implements com.google.gson.TypeAdapterFactory -keep class * implements com.google.gson.JsonSerializer -keep class * implements com.google.gson.JsonDeserializer -keepclassmembers,allowobfuscation class * { @com.google.gson.annotations.SerializedName ; } -keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken -keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken # Glide -keep public class * implements com.bumptech.glide.module.GlideModule -keep class * extends com.bumptech.glide.module.AppGlideModule { (...); } -keep public enum com.bumptech.glide.load.ImageHeaderParser$** { **[] $VALUES; public *; } -keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { *** rewind(); } # for DexGuard only #-keepresourcexmlelements manifest/application/meta-data@value=GlideModule # retrofit2 -dontnote retrofit2.Platform -dontwarn retrofit2.Platform$Java8 -dontnote retrofit2.Platform$IOS$MainThreadExecutor -keepattributes Exceptions -keepclassmembers,allowshrinking,allowobfuscation interface * { @retrofit2.http.* ; } -dontwarn javax.annotation.** # okhttp3 -keep class okhttp3.**{*;} -dontwarn okhttp3.** -keep class okio.**{*;} -dontwarn okio.** #微信 -keep class com.tencent.mm.opensdk.** {*;} -keep class com.tencent.wxop.** {*;} -keep class com.tencent.mm.sdk.** {*;} -keep class com.tencent.mmkv.** {*;} #X5 -dontwarn dalvik.** -dontwarn com.tencent.smtt.** -keep class com.tencent.smtt.** { *; } -keep class com.tencent.tbs.** { *; } #shanyan -dontwarn com.cmic.gen.sdk.** -keep class com.cmic.gen.sdk.**{*;} -dontwarn com.sdk.** -keep class com.sdk.** { *;} -dontwarn com.unikuwei.mianmi.account.shield.** -keep class com.unikuwei.mianmi.account.shield.** {*;} -keep class cn.com.chinatelecom.account.**{*;} -dontwarn com.chuanglan.shanyan_sdk.** -keep class com.chuanglan.shanyan_sdk.** { *;} #oss -keep class com.alibaba.sdk.android.oss.** { *; } -dontwarn okio.** -dontwarn org.apache.commons.codec.binary.** #umeng -keep public class javax.** -dontwarn com.umeng.** -dontwarn com.squareup.okhttp.** -keep public class android.webkit.** -keep public interface com.umeng.socialize.** -keep public interface com.umeng.socialize.sensor.** -keep public interface com.umeng.scrshot.** -keep public class com.umeng.socialize.* {*;} -keep class com.umeng.** {*;} -keep class com.umeng.** #other -dontwarn com.baidu.** -keep class com.baidu.**{*;}