VidiDin-Android/core/architecture/proguard-rules.pro

161 lines
5.6 KiB
Prolog
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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
-dontwarn com.ama.core.common.interfaces.empty.DefaultActivityLifecycleCallbacks
# ---------------------------------- 基础配置 ----------------------------------
# 代码优化次数通常设为5
-optimizationpasses 5
# 不使用混合大小写类名
-dontusemixedcaseclassnames
# 不忽略非公共库类
-dontskipnonpubliclibraryclasses
# 不进行预校验Android不需要可加快速度
-dontpreverify
# 打印混淆详情
-verbose
# 忽略警告
-ignorewarnings
# ---------------------------------- 保留重要属性 ----------------------------------
# 保留泛型签名重要避免JSON解析等类型转换错误
-keepattributes Signature
# 保留注解(如@Keep, @SerializedName等
-keepattributes *Annotation*
# 保留异常信息
-keepattributes Exceptions
# 保留源代码文件名和行号(便于崩溃日志分析)
-keepattributes SourceFile,LineNumberTable
# ---------------------------------- 保留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
# 保持 Native 方法不被混淆
-keepclasseswithmembernames class * {
native <methods>;
}
# 保持 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;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# 保持自定义 View 的构造方法不被混淆(用于 XML 布局)
-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*(...);
}
# 保持枚举类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# 保持由 JSON 转换的 Bean 类(或者你的数据模型类)不被混淆
-keep class com.gamedog.vididin.beans.** { *; }
-keep class com.gamedog.vididin.router.** { *; }
# 保留R文件中的静态字段保证资源反射能正常工作
-keepclassmembers class **.R$* {
public static <fields>;
}
# gson
-keep class com.google.gson.** { *; }
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
# 明确保护被@SerializedName注解的字段
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName <fields>;
}
#okhttp
# OkHttp3
-dontwarn okhttp3.**
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okio.**
# Retrofit2
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature, Exceptions
# --------------------------------------------------
# Hilt 核心规则
# --------------------------------------------------
# 保留 Hilt 的注解处理器生成的类
-keep class dagger.hilt.internal.aggregatedroot.** { *; }
-keep class hilt_aggregated_deps.** { *; }
# 保留使用 @AndroidEntryPoint 注解的 Android 组件Activity, Fragment, View, Service, BroadcastReceiver
-keep class * extends android.app.Application { @dagger.hilt.android.AndroidEntryPoint <init>(); }
-keepclasseswithmembers class * { @dagger.hilt.android.AndroidEntryPoint <fields>; }
-keepclasseswithmembers class * { @dagger.hilt.android.AndroidEntryPoint <methods>; }
# 保留 Hilt 模块类,确保依赖提供逻辑不被混淆
-keep @dagger.Module class *
-keep @dagger.hilt.InstallIn class *
# 保留 Hilt 入口点EntryPoint相关的类
-keep @dagger.hilt.EntryPoint class *
-keepclassmembers @dagger.hilt.EntryPoint class * { *; }
# 保留 Hilt 生成的组件Component相关类
-keep @dagger.hilt.components.SingletonComponent class *
-keepclassmembers @dagger.hilt.components.SingletonComponent class * { *; }
# 保留 Hilt 处理器生成的工厂类
-keep class * extends dagger.internal.Binding { *; }
-keep class * extends dagger.internal.Factory { *; }
-keep class * implements dagger.MembersInjector { *; }
-keep class * implements dagger.Lazy { *; }
# 保留泛型信息,这对依赖注入很关键
-keepattributes Signature, InnerClasses, EnclosingMethod
# 保留注解信息Hilt 严重依赖注解)
-keepattributes *Annotation*