# 代码混淆压缩比,在0~7之间 -optimizationpasses 5 # 混合时不使用大小写混合,混合后的类名为小写 -dontusemixedcaseclassnames # 指定不去忽略非公共库的类 -dontskipnonpubliclibraryclasses # 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。 -dontpreverify -verbose #google推荐算法 -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* # 避免混淆Annotation、内部类、泛型、匿名类 -keepattributes *Annotation*,InnerClasses,Signature,EnclosingMethod,Exceptions # 重命名抛出异常时的文件名称 -renamesourcefileattribute Source # 抛出异常时保留代码行号 -keepattributes SourceFile,LineNumberTable # 保持自定义控件类不被混淆 -keepclassmembers 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 (android.content.Context, android.util.AttributeSet, int, int); public void set*(...); *** get*(); } # 保留R下面的资源 -keep class **.R$* {*;} # 保留四大组件,自定义的Application等这些类不被混淆 # -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.content.ContentProvider -keep public class * extends android.preference.Preference # 保留在Activity中的方法参数是view的方法, # 这样以来我们在layout中写的onClick就不会被影响 -keepclassmembers class * extends android.app.Activity{ public void *(android.view.View); } # 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆 -keepclassmembers class * { void *(**On*Event); void *(**On*Listener); } # 保留本地native方法不被混淆 -keepclasseswithmembers class * { native ; } # 保留枚举类不被混淆 -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } # 保留Parcelable序列化类不被混淆 -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } -keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; 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(); } #assume no side effects:删除android.util.Log输出的日志 -assumenosideeffects class android.util.Log { public static *** v(...); public static *** d(...); public static *** i(...); public static *** w(...); public static *** e(...); } # 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); } # Retain service method parameters when optimizing. -keepclassmembers,allowshrinking,allowobfuscation interface * { @retrofit2.http.* ; } # Platform calls Class.forName on types which do not exist on Android to determine platform. -dontnote retrofit2.Platform # Platform used when running on RoboVM on iOS. Will not be used at runtime. -dontnote retrofit2.Platform$IOS$MainThreadExecutor # Platform used when running on Java 8 VMs. Will not be used at runtime. -dontwarn retrofit2.Platform$Java8 # Ignore annotation used for build tooling. -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement # Ignore JSR 305 annotations for embedding nullability information. -dontwarn javax.annotation.** # JSR 305 annotations are for embedding nullability information. -dontwarn javax.annotation.** # A resource is loaded with a relative path so the package of this class must be preserved. -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. -dontwarn org.codehaus.mojo.animal_sniffer.* # OkHttp platform used only on JVM and when Conscrypt dependency is available. -dontwarn okhttp3.internal.platform.ConscryptPlatform -keep class cn.jzvd.*{*;} -keep class com.gyf.immersionbar.* {*;} -dontwarn com.gyf.immersionbar.** -keep class com.huanchengfly.tieba.post.models.** { *; } -keep class com.huanchengfly.tieba.post.api.models.** { *; } -keep public class com.huanchengfly.tieba.post.utils.TiebaLiteJavaScript { *; } -dontwarn com.yanzhenjie.permission.** -keep public class * implements com.bumptech.glide.module.GlideModule -keep public class * extends com.bumptech.glide.module.AppGlideModule -keep public enum com.bumptech.glide.load.ImageHeaderParser$** { **[] $VALUES; public *; } # LitePal相关 -keep class org.litepal.** { *; } -keep class * extends org.litepal.crud.LitePalSupport { *; } -keep class * implements com.google.gson.JsonDeserializer { *; } # Matisse -dontwarn com.squareup.picasso.** -dontwarn com.zhihu.matisse.** -keep class com.zhihu.matisse.**{*;} -keep class com.lijiankun24.** { *; } # uCrop -dontwarn com.yalantis.ucrop** -keep class com.yalantis.ucrop** { *; } -keep interface com.yalantis.ucrop** { *; } # kotlin -keep class kotlin.** { *; } -keep class kotlin.Metadata { *; } -dontwarn kotlin.** -keepclassmembers class **$WhenMappings { ; } -keepclassmembers class kotlin.Metadata { public ; } -assumenosideeffects class kotlin.jvm.internal.Intrinsics { static void checkParameterIsNotNull(java.lang.Object, java.lang.String); } # OkHttp3 -dontwarn okhttp3.logging.** -keep class okhttp3.internal.**{*;} -dontwarn okio.** # Retrofit -dontwarn retrofit2.** -keep class retrofit2.** { *; } -keep class com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx { *; } -keep class androidx.recyclerview.widget.RecyclerView$LayoutManager { *; } -keep class androidx.recyclerview.widget.RecyclerView$LayoutParams { *; } -keep class androidx.recyclerview.widget.RecyclerView$ViewHolder { *; } -keep class androidx.recyclerview.widget.ChildHelper { *; } -keep class androidx.recyclerview.widget.ChildHelper$Bucket { *; } -keep class com.huanchengfly.tieba.post.plugins.** { *; } -keep class com.squareup.wire.** { *; } # Keep `Companion` object fields of serializable classes. # This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects. -if @kotlinx.serialization.Serializable class ** -keepclassmembers class <1> { static <1>$Companion Companion; } # Keep `serializer()` on companion objects (both default and named) of serializable classes. -if @kotlinx.serialization.Serializable class ** { static **$* *; } -keepclassmembers class <2>$<3> { kotlinx.serialization.KSerializer serializer(...); } # Keep `INSTANCE.serializer()` of serializable objects. -if @kotlinx.serialization.Serializable class ** { public static ** INSTANCE; } -keepclassmembers class <1> { public static <1> INSTANCE; kotlinx.serialization.KSerializer serializer(...); } # @Serializable and @Polymorphic are used at runtime for polymorphic serialization. -keepattributes RuntimeVisibleAnnotations,AnnotationDefault # Serializer for classes with named companion objects are retrieved using `getDeclaredClasses`. # If you have any, uncomment and replace classes with those containing named companion objects. #-keepattributes InnerClasses # Needed for `getDeclaredClasses`. #-if @kotlinx.serialization.Serializable class #com.example.myapplication.HasNamedCompanion, # <-- List serializable classes with named companions. #com.example.myapplication.HasNamedCompanion2 #{ # static **$* *; #} #-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept. # static <1>$$serializer INSTANCE; #} -dontwarn org.bouncycastle.jsse.BCSSLParameters -dontwarn org.bouncycastle.jsse.BCSSLSocket -dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider -dontwarn org.conscrypt.Conscrypt$Version -dontwarn org.conscrypt.Conscrypt -dontwarn org.conscrypt.ConscryptHostnameVerifier -dontwarn org.openjsse.javax.net.ssl.SSLParameters -dontwarn org.openjsse.javax.net.ssl.SSLSocket -dontwarn org.openjsse.net.ssl.OpenJSSE # Compose Runtime Tracing -assumenosideeffects public class androidx.compose.runtime.ComposerKt { boolean isTraceInProgress(); void traceEventStart(int,int,int,java.lang.String); void traceEventStart(int,java.lang.String); void traceEventEnd(); } # Keep generic signature of Flow (R8 full mode strips signatures from non-kept items). -keep,allowobfuscation,allowshrinking class kotlinx.coroutines.flow.Flow -keep,allowobfuscation,allowshrinking class * extends kotlinx.coroutines.flow.Flow -keep,allowobfuscation,allowshrinking class kotlinx.coroutines.Deferred -keep,allowobfuscation,allowshrinking class * extends kotlinx.coroutines.Deferred -keep,allowobfuscation,allowshrinking class com.huanchengfly.tieba.post.api.retrofit.ApiResult -keep,allowobfuscation,allowshrinking class * extends com.huanchengfly.tieba.post.api.retrofit.ApiResult -keep,allowobfuscation,allowshrinking interface retrofit2.Call -keep,allowobfuscation,allowshrinking class retrofit2.Response -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation # Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher. -keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken -keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken -keep,allowobfuscation,allowshrinking class com.billy.android.preloader.** { *; } -keep,allowobfuscation,allowshrinking class com.huanchengfly.tieba.post.utils.preload.** { *; } -if interface * { @retrofit2.http.* ; } -keep,allowobfuscation interface <1> -keepclassmembers,allowobfuscation class * { @com.google.gson.annotations.SerializedName ; }