修复 R8 裁剪 Room 构造器导致的 release 启动闪退,并保留 Gson 备份字段名

This commit is contained in:
2026-10-14 14:04:45 +08:00
parent 3aa6da26a9
commit f5735956c8
+9 -1
View File
@@ -21,13 +21,21 @@
#-renamesourcefileattribute SourceFile
# Room
-keep class * extends androidx.room.RoomDatabase
# Room instantiates its generated *_Impl classes reflectively; R8 full mode
# (AGP 9 default) strips the no-arg constructor unless explicitly kept.
-keep class * extends androidx.room.RoomDatabase { <init>(); }
-dontwarn androidx.room.paging.**
-keep @androidx.room.Entity class *
-keep class * {
@androidx.room.PrimaryKey <fields>;
}
# Gson reflection: BackupManager serializes these models and the field names
# are the on-disk JSON schema of backup files. Without keeps R8 renames the
# fields and backups silently change format between build types.
-keep class cn.airnan.a2fair.data.entity.Token { <fields>; }
-keep class cn.airnan.a2fair.core.backup.BackupData { <fields>; }
# JNI
-keepclasseswithmembernames class * {
native <methods>;