# 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 # 代码混淆压缩比,在0~7之间,默认为5,一般不下需要修改 -optimizationpasses 5 ## 混淆时不使用大小写混合,混淆后的类名为小写 ## windows下的同学还是加入这个选项吧(windows大小写不敏感) -dontusemixedcaseclassnames # ## 指定不去忽略非公共的库的类 ## 默认跳过,有些情况下编写的代码与类库中的类在同一个包下,并且持有包中内容的引用,此时就需要加入此条声明 -dontskipnonpubliclibraryclasses # ## 指定不去忽略非公共的库的类的成员 -dontskipnonpubliclibraryclassmembers # 不做预检验,preverify是proguard的四个步骤之一 # Android不需要preverify,去掉这一步可以加快混淆速度 -dontpreverify # 有了verbose这句话,混淆后就会生成映射文件 -verbose #apk 包内所有 class 的内部结构 -dump class_files.txt #未混淆的类和成员 -printseeds seeds.txt #列出从 apk 中删除的代码 -printusage unused.txt #混淆前后的映射 -printmapping mapping.txt # 指定混淆时采用的算法,后面的参数是一个过滤器 # 这个过滤器是谷歌推荐的算法,一般不改变 -optimizations !code/simplification/artithmetic,!field/*,!class/merging/* # 保护代码中的Annotation不被混淆 # 这在JSON实体映射时非常重要,比如fastJson -keepattributes *Annotation* # 避免混淆泛型 # 这在JSON实体映射时非常重要,比如fastJson -keepattributes Signature # 抛出异常时保留代码行号 -keepattributes SourceFile,LineNumberTable # 实体类不混淆 -keep class com.emato.ich.entity.** {*;} -keep class com.emato.ich.entity.vo.** {*;} # 不需要混淆的安卓类 -keep public class * extends android.app.Fragment -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.preference.Preference -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 # support下所有类及其内部类 -keep class android.support.** {*;} -dontwarn android.support.** -keep interface android.support.** { *; } # androidx -keep class androidx.** {*;} -keep interface androidx.** {*;} -keep public class * extends androidx.** -keep class com.google.android.material.** {*;} -dontwarn com.google.android.material.** -dontnote com.google.android.material.** -dontwarn androidx.** # support v4/7库 -keep public class * extends android.support.v4.** -keep public class * extends android.support.v7.** -keep public class * extends android.support.annotation.** # support design库 -dontwarn android.support.design.** -keep class android.support.design.** { *; } -keep interface android.support.design.** { *; } -keep public class android.support.design.R$* { *; } # 资源文件 -keep class **.R$* {*;} # 避免layout中onClick方法混淆(android:onclick="onClick") -keepclassmembers class * extends android.app.Activity{ public void *(android.view.View); } # 避免回调函数 onXXEvent混淆 -keepclassmembers class * { void *(*Event); } # 避免枚举混淆 -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } # Native方法不混淆 -keepclasseswithmembernames class * { native ; } # 避免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 ; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); } # 避免okhttp3混淆 -keep class okhttp3.** { *; } -keep interface okhttp3.** { *; } -dontwarn okhttp3.** -dontwarn com.squareup.okhttp3.** -keep class com.squareup.okhttp3.** { *;} -dontwarn okio.** -dontwarn com.squareup.** -keep public class org.codehaus.* { *; } -keep public class java.nio.* { *; } -dontwarn org.codehaus.mojo.animal_sniffer.* # 避免小铁sdk混淆 -keep class com.cherry.sdk.controller.** { *; } -keep class com.cherry.sdk.controller.callback.** { *; } -keep class com.cherry.sdk.controller.command.** { *; } -keep class com.cherry.sdk.controller.data.** { *; } -keep class com.cherry.sdk.controller.module.** { *; } -keep class com.cherry.sdk.controller.utils.** { *; } # 远程更新下载jar混淆配置 -dontwarn com.arialyy.aria.** -keep class com.arialyy.aria.**{*;} -keep class **$$DownloadListenerProxy{ *; } -keep class **$$UploadListenerProxy{ *; } -keep class **$$DownloadGroupListenerProxy{ *; } -keep class **$$DGSubListenerProxy{ *; } -keepclasseswithmembernames class * { @Download.* ; @Upload.* ; @DownloadGroup.* ; } # XUpdate混淆配置 -keep class com.xuexiang.xupdate.entity.** { *; } # 注意,如果你使用的是自定义Api解析器解析,还需要给你自定义Api实体配上混淆,如下是本demo中配置的自定义Api实体混淆规则: -keep class com.xuexiang.xupdatedemo.entity.** { *; } # gson -dontwarn sun.misc.** -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 ; } # okhttputils -dontwarn com.zhy.http.** -keep class com.zhy.http.**{*;} -keep interface com.zhy.http.**{*;}