From 8bf3d53448b77c10aea7fb974f940d5306f55264 Mon Sep 17 00:00:00 2001 From: gronod Date: Sun, 14 Jun 2026 13:51:52 +0100 Subject: [PATCH] Refine ProGuard rules: add crash reporting attributes, tighten Room/serialization keeps, preserve enums and framework classes --- app/proguard-rules.pro | 44 +++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 49a48f9..af977d7 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,31 +1,39 @@ # ProGuard rules for ESP32 ALDL Dashboard # Compose + Room + Kotlin Serialization + Navigation3 -# --- General --- +# --- Crash stack traces: preserve file names and line numbers --- +-keepattributes SourceFile,LineNumberTable +-renamesourcefileattribute SourceFile + +# --- General reflection / generic type preservation --- -keepattributes *Annotation* -keepattributes Signature -keepattributes InnerClasses -keepattributes EnclosingMethod # --- Room --- --keep class * extends androidx.room.RoomDatabase --keep class * { @androidx.room.* ; } --dontwarn androidx.room.paging.** +# RoomDatabase subclass is instantiated by reflection +-keep class * extends androidx.room.RoomDatabase { *; } +# Keep all @Entity, @Dao, @Database annotated members +-keep @androidx.room.Entity class * { *; } +-keep @androidx.room.Dao interface * { *; } +-keep @androidx.room.Database class * { *; } # --- Kotlin Serialization --- --keep class kotlinx.serialization.** { *; } --keepclassmembers class ** { - static ** \]serializerInstance; +# Only nav key objects annotated with @Serializable need explicit protection; +# the Kotlin compiler plugin generates keep rules for everything else. +-keep @kotlinx.serialization.Serializable class com.gronod.esp32aldldashboard.** { *; } + +# --- Enums --- +# Preserve enum names used by Room, Bluetooth state, and conditional logic +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); } -# --- Compose / Navigation3 --- --keep class androidx.navigation3.** { *; } --keepclassmembers class * { - @androidx.compose.runtime.Composable ; -} - -# --- DataStore --- --keep class androidx.datastore.** { *; } - -# --- Keep all app classes (safe for now) --- --keep class com.gronod.esp32aldldashboard.** { *; } \ No newline at end of file +# --- Application, Service, ViewModel, and Factory --- +# These are instantiated by the Android framework or ViewModelProvider via reflection +-keep class com.gronod.esp32aldldashboard.AldlApplication { *; } +-keep class com.gronod.esp32aldldashboard.bluetooth.BluetoothForegroundService { *; } +-keep class * extends androidx.lifecycle.ViewModel { *; } +-keep class * extends androidx.lifecycle.ViewModelProvider$Factory { *; } \ No newline at end of file