123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- # 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
- #不跳过非公共的库的类成员
- -dontskipnonpubliclibraryclassmembers
- #混淆时采用的算法
- -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
- #把混淆类中的方法名也混淆了
- -useuniqueclassmembernames
- #指定不去忽略非公共的库的类
- -dontskipnonpubliclibraryclasses
- #不做预检验,preverify是proguard的四大步骤之一,可以加快混淆速度
- #-dontpreverify
- # 忽略警告(?)
- #-ignorewarnings
- #混淆时不使用大小写混合,混淆后的类名为小写(大小写混淆容易导致class文件相互覆盖)
- -dontusemixedcaseclassnames
- #优化时允许访问并修改有修饰符的类和类的成员
- -allowaccessmodification
- #将文件来源重命名为“SourceFile”字符串
- #-renamesourcefileattribute SourceFile
- #保留行号
- -keepattributes SourceFile,LineNumberTable
- #保持泛型
- -keepattributes Signature
- # 保持注解
- -keepattributes *Annotation*,InnerClasses
- # Parcelable
- -keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
- }
- # Serializable
- -keepnames class * implements java.io.Serializable
- -keepclassmembers class * implements java.io.Serializable {
- 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();
- }
- ##---------------Begin: proguard configuration for Gson ----------
- # Gson uses generic type information stored in a class file when working with fields. Proguard
- # removes such information by default, so configure it to keep all of it.
- -keepattributes Signature
- # For using GSON @Expose annotation
- -keepattributes *Annotation*
- # Gson specific classes
- -dontwarn sun.misc.**
- #-keep class com.google.gson.stream.** { *; }
- # Application classes that will be serialized/deserialized over Gson
- -keep class com.google.gson.examples.android.model.** { <fields>; }
- # Prevent proguard from stripping interface information from TypeAdapterFactory,
- # JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
- -keep class * implements com.google.gson.TypeAdapterFactory
- -keep class * implements com.google.gson.JsonSerializer
- -keep class * implements com.google.gson.JsonDeserializer
- # Prevent R8 from leaving Data object members always null
- -keepclassmembers,allowobfuscation class * {
- @com.google.gson.annotations.SerializedName <fields>;
- }
- ##---------------End: proguard configuration for Gson ----------
- # 保留R下面的资源
- -keep class **.R$* {*;}
- # 保留四大组件,自定义的Application,Fragment等这些类不被混淆
- -keep public class * extends android.app.Activity
- -keep public class * extends android.app.Fragment
- -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
- ## support
- -dontwarn android.support.**
- -keep class android.support.v4.app.** { *; }
- -keep interface android.support.v4.app.** { *;}
- -keep public class * extends android.support.v7.**
- -keep public class * extends android.support.annotation.**
- -keep public class * extends android.support.v4.view.ActionProvider {
- public <init>(android.content.Context);
- }
- # 保留枚举类不被混淆
- -keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
- }
- # 保留本地native方法不被混淆
- -keepclasseswithmembers class * {
- native <methods>;
- }
- # 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
- -keepclassmembers class * {
- void *(**On*Event);
- void *(**On*Listener);
- }
- -keepclassmembers public class * extends android.view.View {
- void set*(***);
- *** get*();
- }
- #保留在Activity中的方法参数是view的方法,
- -keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
- }
- # For XML inflating, keep views' constructoricon.png 自定义view
- -keep public class * extends android.view.View {
- public <init>(android.content.Context);
- public <init>(android.content.Context, android.util.AttributeSet);
- public <init>(android.content.Context, android.util.AttributeSet, int);
- public void set*(...);
- }
- # androidx 混淆
- -keep class com.google.android.material.** {*;}
- -keep class androidx.** {*;}
- -keep public class * extends androidx.**
- -keep interface androidx.** {*;}
- -dontwarn com.google.android.material.**
- -dontnote com.google.android.material.**
- -dontwarn androidx.**
- -printconfiguration
- -keep,allowobfuscation @interface androidx.annotation.Keep
- -keep @androidx.annotation.Keep class *
- -keepclassmembers class * {
- @androidx.annotation.Keep *;
- }
- # 内部WebView混淆过滤
- -keepclassmembers class * {
- @android.webkit.JavascriptInterface <methods>;
- }
- -keep class com.naz.sdkdemo.bean.**{*;}
- -keepclassmembers class *{
- public<init>(org.json.JSONObject);
- }
- -keepclassmembers enum *{
- publicstatic**[] values();
- publicstatic** valueOf(java.lang.String);
- }
- #okhttp
- -dontwarn okhttp3.**
- -keep class okhttp3.**{*;}
- #okio
- -dontwarn okio.**
- -keep class okio.**{*;}
|