首次提交

This commit is contained in:
2025-11-20 17:48:34 +08:00
commit 94baa16c92
61 changed files with 375904 additions and 0 deletions

View File

@@ -0,0 +1,424 @@
# ==================== 基础混淆配置 ====================
# 指定代码的压缩级别 0 - 7(指定代码进行迭代优化的次数在Android里面默认是5这条指令也只有在可以优化时起作用)
-optimizationpasses 5
# 混淆时不会产生形形色色的类名(混淆时不使用大小写混合类名)
-dontusemixedcaseclassnames
# 指定不去忽略非公共的库类(不跳过library中的非public的类)
-dontskipnonpubliclibraryclasses
# 指定不去忽略非公共的的库类的成员
-dontskipnonpubliclibraryclassmembers
#不进行预校验,Android不需要,可加快混淆速度
-dontpreverify
# 混淆时记录日志(打印混淆的详细信息)
# 这句话能够使我们的项目混淆后产生映射文件
# 包含有类名->混淆后类名的映射关系
-verbose
# 指定混淆是采用的算法,后面的参数是一个过滤器
# 这个过滤器是谷歌推荐的算法,一般不做更改
-optimizations !code/simplification/cast,!field/*,!class/merging/*
#保护代码中的 Annotation 内部类不被混淆
-keepattributes *Annotation*,InnerClasses,EnclosingMethod
#-ignorewarnings
# 避免混淆泛型,这在 JSON 实体映射时非常重要,比如 fastJson
-keepattributes Signature
# 抛出异常时保留代码行号,在异常分析中可以方便定位
-keepattributes SourceFile,LineNumberTable
#-adaptclassstrings
# ==================== Android 基础组件 ====================
# 保留四大组件及其子类
-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 com.android.vending.licensing.ILicensingService
# 保留 View 的构造方法和 getter/setter
-keepclassmembers 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);
void set*(***);
*** get*();
}
# 保留自定义控件(继承自 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);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# 保留在 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);
}
# 对于 R资源下的所有类及其方法都不能被混淆
-keep class **.R$* {
*;
}
# 保留 R 文件中的所有静态字段
-keepclassmembers class **.R$* {
public static <fields>;
}
# 对于带有回调函数 onXXEvent 的,不能被混淆
-keepclassmembers class * {
void *(**On*Event);
}
-keepclassmembers class * {
public <init>(org.json.JSONObject);
}
-keepattributes *JavascriptInterface*
# ==================== JNI 和 Native 方法 ====================
# 保留所有 native 方法
-keepclasseswithmembernames class * {
native <methods>;
}
# AIDL文件不能被混淆
-keep class * implements android.os.IInterface {*;}
-keep class * extends android.os.Binder {*;}
-keep class * extends android.os.IInterface {*;}
# ==================== 序列化相关 ====================
# 保留 Parcelable 序列化的类
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
# 保留 Parcelable 序列化的类不被混淆
#-keep class * implements android.os.Parcelable {
# *;
#}
# 保留 Serializable 序列化的类
-keep class * implements java.io.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();
}
# ==================== Kotlin 语言特性支持 ====================
# 保留 Kotlin 元数据注解
-keepattributes *Annotation*
-keep class kotlin.Metadata
# 保留 Kotlin 反射相关
-keep class kotlin.reflect.** { *; }
-keep interface kotlin.reflect.** { *; }
-dontwarn kotlin.reflect.**
## 保持反射相关
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations
# 保留 Kotlin 内置类和函数
-keep class kotlin.** { *; }
-keep class kotlin.jvm.internal.** { *; }
-keep class kotlin.jvm.functions.** { *; }
-keepclassmembers class **$WhenMappings {
<fields>;
}
# ==================== Kotlin 协程支持 ====================
# 保留协程相关类
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler {}
# 保留协程调试信息
-keep class kotlinx.coroutines.** { *; }
-dontwarn kotlinx.coroutines.**
# 保留挂起函数的 Continuation 参数
-keepclassmembernames class * {
*** *Continuation;
}
# ==================== Kotlin 数据类和密封类 ====================
# 保留数据类的 copy 方法和组件函数
-keepclassmembers class * {
*** copy(...);
*** component*();
}
# 保留密封类的子类信息
-keep class * extends kotlin.coroutines.jvm.internal.SuspendLambda { *; }
-keep class * extends kotlin.jvm.internal.Lambda { *; }
# ==================== Kotlin 委托属性 ====================
# 保留属性委托相关
-keep class kotlin.properties.** { *; }
-keep interface kotlin.properties.** { *; }
# 保留 lazy 委托
-keep class kotlin.Lazy { *; }
-keep class kotlin.LazyKt { *; }
# ==================== Kotlin 扩展函数 ====================
# 保留扩展函数(通常编译为静态方法)
-keepclassmembers class * {
public static *** *Kt(...);
}
# 保留 Kotlin 文件级函数
-keep class **.*Kt { *; }
# ==================== Kotlin 内联类和值类 ====================
# 保留内联类的装箱/拆箱方法
-keepclassmembers @kotlin.jvm.JvmInline class * {
public *** box-impl(...);
public static *** unbox-impl(...);
public static *** constructor-impl(...);
public static boolean equals-impl(...);
public static int hashCode-impl(...);
public static java.lang.String toString-impl(...);
}
# ==================== Kotlin 注解处理 ====================
# 保留 Kotlin 编译器生成的注解
-keep @interface kotlin.jvm.** { *; }
-keep @interface kotlin.** { *; }
# 保留使用了特定注解的类和成员
-keep @kotlin.jvm.JvmStatic class * { *; }
-keep @kotlin.jvm.JvmOverloads class * { *; }
-keep @kotlin.jvm.JvmField class * { *; }
# ==================== Kotlin 对象和伴生对象 ====================
# 保留 object 单例类
-keepclassmembers class * {
public static final *** INSTANCE;
}
# 保留伴生对象
-keepclassmembers class * {
public static final *** Companion;
}
# 保留伴生对象的成员
-keepclassmembers class **$Companion {
public <fields>;
public <methods>;
}
# 保留使用 @JvmStatic 注解的方法
-keepclassmembers class * {
@kotlin.jvm.JvmStatic <methods>;
}
# 保留使用 @JvmField 注解的字段
-keepclassmembers class * {
@kotlin.jvm.JvmField <fields>;
}
# ==================== Kotlin 序列化支持 ====================
# 如果使用了 Kotlin Serialization
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt
-keepclassmembers class kotlinx.serialization.json.** {
*** Companion;
}
-keepclasseswithmembers class kotlinx.serialization.json.** {
kotlinx.serialization.KSerializer serializer(...);
}
# ==================== Kotlin 集合和函数式编程 ====================
# 保留 Kotlin 集合扩展
-keep class kotlin.collections.** { *; }
-keep class kotlin.sequences.** { *; }
# 保留函数式接口
-keep interface kotlin.jvm.functions.Function* { *; }
# 保留 SAM 转换相关
-keep class kotlin.jvm.internal.FunctionReference* { *; }
-keep class kotlin.jvm.internal.PropertyReference* { *; }
# ==================== Kotlin 类型别名 ====================
# 保留类型别名信息(通过元数据)
-keepattributes kotlin.Metadata
# ==================== 调试和错误处理 ====================
# 保留 Kotlin 异常相关
-keep class kotlin.KotlinNullPointerException { *; }
-keep class kotlin.UninitializedPropertyAccessException { *; }
-keep class kotlin.NoWhenBranchMatchedException { *; }
# ==================== 性能优化 ====================
# 允许优化 Kotlin 内联函数
#-allowaccessmodification
#-repackageclasses
# 但保留重要的调试信息
-keepattributes SourceFile,LineNumberTable,*Annotation*
# ==================== 警告抑制 ====================
# 忽略 Kotlin 相关警告
-dontwarn kotlin.**
-dontwarn kotlinx.**
-dontwarn org.jetbrains.annotations.**
# ==================== 网络库配置 ====================
# Retrofit 配置
-keepattributes Signature, InnerClasses, EnclosingMethod
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepattributes AnnotationDefault
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}
# OkHttp 配置
-dontwarn okhttp3.**
-dontwarn okio.**
-keep class okhttp3.** { *; }
-keep class okio.** { *; }
-dontwarn javax.annotation.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
# Gson 配置
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.** { *; }
-keep class * extends com.google.gson.TypeAdapter
-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 <fields>;
}
# ==================== 图片加载库 ====================
# Glide 配置
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
<init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}
# ==================== 项目特定配置 ====================
# 保留项目核心包结构
#-keep class com.coocaa.icast.** { *; }
#-keep class com.xlink.cast.** { *; }
# 保留 XLink SDK 相关
#-keep class com.coocaa.xlink.** { *; }
#-keep interface com.coocaa.xlink.** { *; }
# 保留实体类和数据模型
-keep class **.*Model { *; }
-keep class **.*Bean { *; }
-keep class **.*Entity { *; }
-keep class **.*Data { *; }
-keep class **.*Response { *; }
-keep class **.*Request { *; }
# 保留可能被反射调用的类
-keepclassmembers class * {
public <init>(...);
}
# ==================== 第三方库配置 ====================
-keep class org.jetbrains.annotations.** { *; }
-keep class org.greenrobot.eventbus.** { *; }
-keep class org.intellij.lang.** { *; }
-keep class tv.danmaku.ijk.** { *; }
-keep class fi.iki.elonen.** { *; }
-keep class net.jpountz.** { *; }
-keep class javax.annotation.** { *; }
# XCrash 崩溃收集
-keep class xcrash.** { *; }
# 多 DEX 支持
-keep class com.android.support.multidex.** { *; }
-keep class androidx.multidex.** { *; }
# AndroidX 相关
-dontwarn androidx.**
# Material Design 组件
-dontwarn com.google.android.material.**
# ==================== WebView 相关 ====================
# 保留 WebView 中的 JS 接口
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepclassmembers class fqcn.of.javascript.interface.for.Webview {
public *;
}
-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);
}