123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- # 代码混淆压缩比,在0~7之间,默认为5,一般不做修改
- -optimizationpasses 5
- # 混合时不使用大小写混合,混合后的类名为小写
- -dontusemixedcaseclassnames
- # 指定不去忽略非公共库的类
- -dontskipnonpubliclibraryclasses
- # 这句话能够使我们的项目混淆后产生映射文件
- # 包含有类名->混淆后类名的映射关系
- -verbose
- # 指定不去忽略非公共库的类成员
- -dontskipnonpubliclibraryclassmembers
- # 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。
- -dontpreverify
- # 保留Annotation不混淆
- -keepattributes *Annotation*,InnerClasses
- # 避免混淆泛型
- -keepattributes Signature
- # 抛出异常时保留代码行号
- #-keepattributes SourceFile,LineNumberTable
- # 指定混淆是采用的算法,后面的参数是一个过滤器
- # 这个过滤器是谷歌推荐的算法,一般不做更改
- -optimizations !code/simplification/cast,!field/*,!class/merging/*
- #-------------------------------------------------------默认保留区----------------------------------------------
- # 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
- # 因为这些子类都有可能被外部调用
- -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 * extends androidx.fragment.app.Fragment
- -keep public class * extends androidx.appcompat.app.AppCompatActivity
- -keep public class * extends androidx.viewbinding.ViewBinding {
- public static <methods>;
- }
- # 保留继承的
- -keep public class * extends android.support.v4.*
- -keep public class * extends android.support.v7.*
- -keep public class * extends android.support.annotation.*
- # 保留本地native方法不被混淆
- -keepclasseswithmembernames class * {
- native <methods>;
- }
- # 保留R下面的资源
- -keep class **.R$* {
- *;
- }
- # 保留在Activity中的方法参数是view的方法,
- # 这样以来我们在layout中写的onClick就不会被影响
- -keepclassmembers class * extends android.app.Activity{
- public void *(android.view.View);
- }
- # 保留枚举类不被混淆
- -keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
- }
- # 保留我们自定义控件(继承自View)不被混淆
- -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);
- }
- # 保留Parcelable序列化类不被混淆
- -keep class * implements android.os.Parcelable {
- *;
- }
- # 保留Serializable序列化的类不被混淆
- -keepclassmembers class * implements java.io.Serializable {
- static final long serialVersionUID;
- private static final java.io.ObjectStreamField[] serialPersistentFields;
- !static !transient <fields>;
- !private <fields>;
- !private <methods>;
- private void writeObject(java.io.ObjectOutputStream);
- private void readObject(java.io.ObjectInputStream);
- java.lang.Object writeReplace();
- java.lang.Object readResolve();
- }
- # 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
- -keepclassmembers class * {
- void *(**On*Event);
- void *(**On*Listener);
- }
- #WebView的处理
- -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, java.lang.String);
- }
- # 移除Log类打印各个等级日志的代码,打正式包的时候可以做为禁log使用,这里可以作为禁止log打印的功能使用
- # 记得proguard-android.txt中一定不要加-dontoptimize才起作用
- # 另外的一种实现方案是通过BuildConfig.DEBUG的变量来控制
- -assumenosideeffects class android.util.Log {
- public static int v(...);
- public static int i(...);
- public static int w(...);
- public static int d(...);
- public static int e(...);
- }
- #xutils
- -keepattributes Signature,*Annotation*
- -keep public class org.xutils.* {
- public protected *;
- }
- -keep public interface org.xutils.* {
- public protected *;
- }
- -keepclassmembers class * extends org.xutils.* {
- public protected *;
- }
- -keepclassmembers @org.xutils.db.annotation.* class * {*;}
- -keepclassmembers @org.xutils.http.annotation.* class * {*;}
- -keepclassmembers class * {
- @org.xutils.view.annotation.Event <methods>;
- }
- #BottomNavigationView
- -keep public class com.google.android.material.bottomnavigation.BottomNavigationView.* { *; }
- -keep public class com.google.android.material.bottomnavigation.BottomNavigationMenuView.* { *; }
- -keep public class com.google.android.material.bottomnavigation.BottomNavigationPresenter.* { *; }
- -keep public class com.google.android.material.bottomnavigation.BottomNavigationItemView.* { *; }
- #af
- -dontwarn com.android.installreferrer
- -dontwarn com.appsflyer.**
- -keep public class com.google.firebase.messaging.FirebaseMessagingService {
- public *;
- }
- -keep class com.google.android.gms.* { *; }
- -keep class com.huawei.hms.ads.* { *; }
- -keep interface com.huawei.hms.ads.* { *; }
- -dontwarn com.alibaba.fastjson.*
- -keep class com.alibaba.fastjson.*{*; }
- -keep class com.just.agentweb.*{*;}
- -dontwarn com.just.agentweb.*
- #-----------------------------------------------------特殊处理部分----------------------------------------------
- # AppCompat
- -keep class androidx.appcompat.** { *; }
- # ConstraintLayout
- -keep class androidx.constraintlayout.** { *; }
- # Legacy Support Library
- -keep class androidx.legacy.** { *; }
- # Material Components
- -keep class com.google.android.material.** { *; }
- # Navigation Component
- -keep class androidx.navigation.** { *; }
- # Lifecycle Extensions
- -keep class androidx.lifecycle.** { *; }
- # RecyclerView
- -keep class androidx.recyclerview.** { *; }
- # ButterKnife
- -keep class butterknife.** { *; }
- -dontwarn butterknife.internal.**
- -keep class **$$ViewBinder { *; }
- -keepclasseswithmembernames class * {
- @butterknife.* <methods>;
- }
- # Retrofit
- -keep class retrofit2.** { *; }
- -keepattributes Signature
- -keepattributes Exceptions
- # RxJava
- -keep class io.reactivex.** { *; }
- # CodeEditor
- -keep class com.ahmadaghazadeh.editor.** { *; }
- # Material Dialogs
- -keep class com.afollestad.materialdialogs.** { *; }
- # BaseRecyclerViewAdapterHelper
- -keep class com.chad.library.adapter.** { *; }
- # LiveEventBus
- -keep class com.jeremyliao.** { *; }
- # Room Persistence Library
- -keep class androidx.room.** { *; }
- -keepclassmembers class androidx.room.** {
- *;
- }
- # UtilCodeX
- -keep class com.blankj.utilcode.** { *; }
- # Work Manager
- -keep class androidx.work.** { *; }
- # XUtils
- -keep class org.xutils.** { *; }
- # Fastjson
- -keep class com.alibaba.fastjson.** { *; }
- # LogView
- -keep class com.sanyinchen.** { *; }
- # AppCenter
- -keep class com.microsoft.appcenter.** { *; }
- -keep class androidx.work.** { *; }
- -dontwarn com.jeremyliao.liveeventbus.**
- -keep class com.jeremyliao.liveeventbus.** { *; }
- -keep class androidx.lifecycle.** { *; }
- -keep class androidx.arch.core.** { *; }
- -keep class com.romellfudi.ussdlibrary.** { *; }
- # 保留 FFmpeg 库的主要类
- -keep class com.arthenica.mobileffmpeg.** { *; }
- # 保留使用的 Native 方法
- -keepclasseswithmembernames class * {
- native <methods>;
- }
- # 保留所有带有 Log 注解的类和方法
- -keep class * {
- @android.util.Log *;
- }
- # 如果你的项目使用了 `FFmpeg` 回调功能,保留回调接口
- -keepclassmembers class com.arthenica.mobileffmpeg.Config {
- public static void enableLogCallback(...);
- public static void enableStatisticsCallback(...);
- }
|