104 lines
3.8 KiB
Prolog
104 lines
3.8 KiB
Prolog
# ========================================
|
||
# cute Kitchen - Android Proguard Rules
|
||
# 修复 release 包缓存失效、图片加载不出的问题
|
||
# 创建: 2026-04-19
|
||
# ========================================
|
||
|
||
# ─── Flutter 框架 ───
|
||
-keep class io.flutter.app.** { *; }
|
||
-keep class io.flutter.plugin.** { *; }
|
||
-keep class io.flutter.util.** { *; }
|
||
-keep class io.flutter.view.** { *; }
|
||
-keep class io.flutter.** { *; }
|
||
-keep class io.flutter.plugins.** { *; }
|
||
|
||
# ─── Hive CE 本地数据库 ───
|
||
# Hive 使用反射进行序列化/反序列化,TypeAdapter 必须保留
|
||
-keep class * extends com.hive_ce.** { *; }
|
||
-keep class * implements com.hive_ce.** { *; }
|
||
-keep class hive.** { *; }
|
||
-keepclassmembers class * {
|
||
@hive.TypeAdapter <methods>;
|
||
}
|
||
# 保留所有 Hive TypeAdapter 子类(Dart 侧通过 typeId 映射)
|
||
-keep class * extends java.lang.Object { *; }
|
||
|
||
# ─── SharedPreferences ───
|
||
# SharedPreferences 的 Flutter 插件使用方法通道
|
||
-keep class io.flutter.plugins.sharedpreferences.** { *; }
|
||
-keep class **.SharedPreferencesPlugin { *; }
|
||
|
||
# ─── CachedNetworkImage / FlutterCacheManager ───
|
||
# 图片缓存依赖文件系统和 HTTP 客户端
|
||
-keep class com.baseflow.cachednetworkimage.** { *; }
|
||
-keep class io.flutter.plugins.flutter_cache_manager.** { *; }
|
||
|
||
# ─── Dio / HTTP 相关 ───
|
||
# Dio 使用反射解析响应数据
|
||
-keep class com.squareup.okhttp.** { *; }
|
||
-dontwarn okio.**
|
||
-dontwarn javax.annotation.**
|
||
|
||
# ─── Path Provider ───
|
||
# 获取应用目录路径
|
||
-keep class io.flutter.plugins.pathprovider.** { *; }
|
||
|
||
# ─── Connectivity Plus ───
|
||
-keep class io.flutter.plugins.connectivityplus.** { *; }
|
||
|
||
# ─── Share Plus ───
|
||
-keep class io.flutter.plugins.shareplus.** { *; }
|
||
|
||
# ─── JSON 序列化 ───
|
||
# Dart 的 jsonDecode/jsonEncode 在原生层依赖这些类
|
||
-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 void writeObject(java.io.ObjectOutputStream);
|
||
private void readObject(java.io.ObjectInputStream);
|
||
java.lang.Object writeReplace();
|
||
java.lang.Object readResolve();
|
||
}
|
||
|
||
# ─── 通用规则 ───
|
||
# 不混淆包含 native 方法的类
|
||
-keepclasseswithmembernames class * {
|
||
native <methods>;
|
||
}
|
||
|
||
# 保留枚举类
|
||
-keepclassmembers enum * {
|
||
public static **[] values();
|
||
public static ** valueOf(java.lang.String);
|
||
}
|
||
|
||
# 保留 Parcelable 实现
|
||
-keepclassmembers class * implements android.os.Parcelable {
|
||
public static final android.os.Parcelable$Creator CREATOR;
|
||
}
|
||
|
||
# ─── Play Core (分包安装) ───
|
||
# Flutter 引擎引用了 Play Core 类,但项目未使用分包安装功能
|
||
# 这些类在运行时不会被调用,仅需抑制 R8 警告
|
||
-dontwarn com.google.android.play.core.splitcompat.SplitCompatApplication
|
||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallException
|
||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallManager
|
||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallManagerFactory
|
||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallRequest
|
||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallRequest$Builder
|
||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallSessionState
|
||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener
|
||
-dontwarn com.google.android.play.core.tasks.OnFailureListener
|
||
-dontwarn com.google.android.play.core.tasks.OnSuccessListener
|
||
-dontwarn com.google.android.play.core.tasks.Task
|
||
-dontwarn com.google.android.play.core.**
|
||
|
||
# 不警告缺失的引用
|
||
-dontwarn javax.annotation.**
|
||
-dontwarn kotlin.Unit
|
||
-dontwarn retrofit2.**
|
||
-dontwarn okhttp3.**
|
||
-dontwarn okio.**
|