From eb941424049064ae3ecd27c78acdeb554c32cad3 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Sun, 24 May 2026 21:15:23 +0800 Subject: [PATCH] fix: add missing ProGuard keep rules to prevent release crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R8 was stripping Android components (services, application), Room entities, Koin modules, and ViewModels — causing crash when VoiceInteractionService was invoked via power button. Co-Authored-By: Claude Opus 4.7 --- app/proguard-rules.pro | 67 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 2d2c2df..9b97839 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,27 +1,68 @@ # Cyrene ProGuard Rules -# Retrofit --keepattributes Signature +# --- Keep Android components declared in manifest --- +# These are instantiated by the Android system via reflection +-keep class top.yeij.cyrene.CyreneApplication { *; } +-keep class top.yeij.cyrene.MainActivity { *; } +-keep class top.yeij.cyrene.service.** { *; } + +# --- Kotlin --- -keepattributes *Annotation* --keep class top.yeij.cyrene.data.remote.dto.** { *; } --dontwarn retrofit2.** --keep class retrofit2.** { *; } - -# Gson --keep class com.google.gson.** { *; } +-keepattributes Signature +-keepattributes InnerClasses -keepattributes EnclosingMethod +-dontwarn kotlin.** -# OkHttp +# --- Retrofit --- +-keep class retrofit2.** { *; } +-dontwarn retrofit2.** + +# --- Gson --- +-keep class com.google.gson.** { *; } +-keepclassmembers,allowobfuscation class * { + @com.google.gson.annotations.SerializedName ; +} +# Keep all DTO classes and their members for Gson serialization +-keep class top.yeij.cyrene.data.remote.dto.** { *; } +-keepclassmembers class top.yeij.cyrene.data.remote.dto.** { *; } + +# --- OkHttp --- -dontwarn okhttp3.** -dontwarn okio.** -# Room --keep class * extends androidx.room.RoomDatabase +# --- Room --- +-keep class * extends androidx.room.RoomDatabase { *; } +-keep class top.yeij.cyrene.data.local.entity.** { *; } +-keepclassmembers class top.yeij.cyrene.data.local.entity.** { *; } -dontwarn androidx.room.paging.** -# Koin +# --- Koin --- -keep class org.koin.** { *; } +-keep class top.yeij.cyrene.di.** { *; } +-keepclassmembers class top.yeij.cyrene.di.** { *; } -# Coroutines +# --- Compose --- +-dontwarn androidx.compose.** +-keep class androidx.compose.** { *; } + +# --- Coroutines --- -keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {} -keepnames class kotlinx.coroutines.CoroutineExceptionHandler {} + +# --- Keep domain models (used in StateFlow, SharedFlow, etc.) --- +-keep class top.yeij.cyrene.domain.model.** { *; } + +# --- Keep ViewModels (Koin instantiates via reflection) --- +-keep class top.yeij.cyrene.viewmodel.** { *; } +-keepclassmembers class top.yeij.cyrene.viewmodel.** { *; } + +# --- Keep repository implementations (Koin binds by interface) --- +-keep class top.yeij.cyrene.data.repository.** { *; } +-keep class top.yeij.cyrene.domain.repository.** { *; } + +# --- Keep PreferencesDataStore (Koin injects) --- +-keep class top.yeij.cyrene.data.local.PreferencesDataStore { *; } + +# --- General AndroidX --- +-keep class androidx.lifecycle.** { *; } +-dontwarn androidx.lifecycle.**