|
|
|
|
# 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
|
|
|
|
|
# 有了verbose这句话,混淆后就会生成映射文件
|
|
|
|
|
# 包含有类名->混淆后类名的映射关系
|
|
|
|
|
# 然后使用printmapping指定映射文件的名称
|
|
|
|
|
-verbose
|
|
|
|
|
-printmapping priguardMapping.txt
|
|
|
|
|
|
|
|
|
|
# 保留所有的本地native方法不被混淆
|
|
|
|
|
-keepclasseswithmembernames class * {
|
|
|
|
|
native <methods>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 保护代码中的Annotation不被混淆
|
|
|
|
|
# 这在JSON实体映射时非常重要,比如fastJson
|
|
|
|
|
-keepattributes *Annotation*
|
|
|
|
|
|
|
|
|
|
# 避免混淆泛型
|
|
|
|
|
# 这在JSON实体映射时非常重要,比如fastJson
|
|
|
|
|
-keepattributes Signature
|
|
|
|
|
|
|
|
|
|
# 抛出异常时保留代码行号
|
|
|
|
|
-keepattributes SourceFile,LineNumberTable
|
|
|
|
|
|
|
|
|
|
# 对R文件下的所有类及其方法,都不能被混淆
|
|
|
|
|
-keepclassmembers class **.R$* {
|
|
|
|
|
*;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 保留了继承自Activity、Application这些类的子类
|
|
|
|
|
# 因为这些子类有可能被外部调用
|
|
|
|
|
# 比如第一行就保证了所有Activity的子类不要被混淆
|
|
|
|
|
-keep public class * extends android.app.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
|
|
|
|
|
|
|
|
|
|
# 枚举类不能被混淆
|
|
|
|
|
-keepclassmembers enum * {
|
|
|
|
|
public static **[] values();
|
|
|
|
|
public static ** valueOf(java.lang.String);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 保留自定义控件(继承自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*(***);
|
|
|
|
|
*** get* ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 保留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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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.**
|
|
|
|
|
|
|
|
|
|
# 保留BaseFragment公共成员和方法不被混淆
|
|
|
|
|
-keep class com.common.commonlib.utils.*{*;}
|
|
|
|
|
|
|
|
|
|
# 保留BaseFragment公共成员和方法不被混淆
|
|
|
|
|
-keep class com.common.commonlib.view.fragment.BaseFragment{
|
|
|
|
|
public<fields>;
|
|
|
|
|
public<methods>;
|
|
|
|
|
}
|
|
|
|
|
# 保留BaseNavigationFragment公共成员和方法不被混淆
|
|
|
|
|
-keep class com.common.commonlib.view.fragment.BaseNavigationFragment{
|
|
|
|
|
public<fields>;
|
|
|
|
|
public<methods>;
|
|
|
|
|
}
|
|
|
|
|
# 保留BaseActivity公共成员和方法不被混淆
|
|
|
|
|
-keep class com.common.commonlib.view.activity.BaseActivity{
|
|
|
|
|
public<fields>;
|
|
|
|
|
public<methods>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 保留CommonTitleView的内部类不被混淆
|
|
|
|
|
-keep class com.common.commonlib.view.CommonTitleView$*{
|
|
|
|
|
*;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 保留BaseNavigationFragment公共成员和方法不被混淆
|
|
|
|
|
-keep class com.common.commonlib.view.SlideRecyclerView{
|
|
|
|
|
public<fields>;
|
|
|
|
|
public<methods>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 保留glide的配置类
|
|
|
|
|
-keep public class * extends com.bumptech.glide.module.AppGlideModule
|
|
|
|
|
-keep class com.bumptech.glide.GeneratedAppGlideModuleImpl
|