fix(train): keep what WorkManager and Polar's firmware service need from R8

v0.1.0 crashed on every start: R8's full mode (AGP 9) took Room 2.6.1's
`-keep class * extends RoomDatabase` to keep no constructor, and WorkManager
creates its database by reflection (NoSuchMethodException
WorkDatabase_Impl.<init>). Checking the Loop's firmware failed too: Polar's
SDK asks through Retrofit 2.9.0, whose rules predate the full mode, and
Retrofit lost the generic signatures of its suspend functions ("Class cannot
be cast to ParameterizedType").

Train's own proguard-rules.pro keeps the database's constructor, adds
Retrofit 2.11's three rules and keeps the firmware service's requests and
replies, which Gson fills. Debug builds don't shrink, so neither showed
before the release; checked on a Pixel 9a with a release build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-01 00:37:47 +01:00
commit 58f9b3a472
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 26 additions and 0 deletions

View file

@ -51,6 +51,8 @@ android {
release {
signingConfig =
signingConfigs.findByName("release") ?: signingConfigs.getByName("debug")
// Train's keep rules for R8, beside the libraries' and Flutter's.
proguardFiles("proguard-rules.pro")
}
}

View file

@ -0,0 +1,24 @@
# Train's own rules for R8, beside those the libraries bring.
# WorkManager (the Loop's and the music's workers, ADR 0030, D37) creates its
# Room database by reflection as the app starts. Room 2.6.1, which WorkManager
# 2.10.1 brings, keeps that class with `-keep class * extends RoomDatabase`
# alone, which R8's full mode (AGP 9's) no longer takes to keep its
# constructor: v0.1.0 crashed on every start with NoSuchMethodException
# WorkDatabase_Impl.<init>. Drop this once Room's own rule keeps it.
-keep class * extends androidx.room.RoomDatabase {
<init>();
}
# Polar's SDK asks Polar's firmware service (ADR 0030, D10, D40) through
# Retrofit 2.9.0, whose rules predate R8's full mode: without the generic
# signatures of its suspend functions (Continuation<Response<…>>) Retrofit
# fails, "Class cannot be cast to ParameterizedType", and checking the Loop's
# firmware did in v0.1.0. These three are Retrofit 2.11's own rules.
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
# The firmware service's requests and replies, which Gson writes and fills by
# reflection.
-keep class com.polar.androidcommunications.http.** { *; }