From 1a66fe2e334aaacdf3ee44773c21f8b2bb956a53 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 21 Sep 2026 11:00:44 -0400 Subject: [PATCH] fix(r8): keep GeocacheTab, the third enum a route argument resolves by name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main stopped shipping `-dontobfuscate` when the R8 work merged, and this branch has since merged main, so its release build renames classes. The geocaching hub takes its tab as a route argument — `Route.Geocaches(initialTab: GeocacheTab?)` — and androidx.navigation resolves an enum argument with Class.forName on the serial name. A renamed GeocacheTab therefore throws while the nav graph is being built, which is before anything is on screen: the app cannot get past login. It is the same failure DiscoverTab and BookmarkType already have keeps for, on an enum added after those were written. The blanket `-keepclassmembers enum *` does not cover it. That rule pins the constant names and deliberately lets the class be renamed, which is exactly what breaks here. Verified on a play release build of this branch: the contract passes 26/26, mapping.txt carries `...routes.GeocacheTab -> ...routes.GeocacheTab`, and the minified APK starts, reaches the feed and opens the geocaching hub with all five tabs — no FATAL EXCEPTION and no "Cannot find class with name". The new contract line was mutation-tested: renaming the class in a copy of the mapping makes the verifier exit 1 and name it. Co-Authored-By: Claude Opus 5 (1M context) --- amethyst/proguard-rules.pro | 1 + tools/r8-verify/reflection-contract.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/amethyst/proguard-rules.pro b/amethyst/proguard-rules.pro index 3e4b2d898d..9de75fd352 100644 --- a/amethyst/proguard-rules.pro +++ b/amethyst/proguard-rules.pro @@ -242,3 +242,4 @@ # breaks here. Every enum used as a route argument needs its name too. -keep class com.vitorpamplona.amethyst.ui.navigation.routes.DiscoverTab { *; } -keep class com.vitorpamplona.amethyst.ui.screen.loggedIn.bookmarkgroups.BookmarkType { *; } +-keep class com.vitorpamplona.amethyst.ui.navigation.routes.GeocacheTab { *; } diff --git a/tools/r8-verify/reflection-contract.txt b/tools/r8-verify/reflection-contract.txt index cad44c3656..4d04998fb8 100644 --- a/tools/r8-verify/reflection-contract.txt +++ b/tools/r8-verify/reflection-contract.txt @@ -123,6 +123,7 @@ class com.vitorpamplona.amethyst.service.calendar.CalendarReminderWorker # renamed. Add a line here whenever an enum becomes a route argument. class com.vitorpamplona.amethyst.ui.navigation.routes.DiscoverTab class com.vitorpamplona.amethyst.ui.screen.loggedIn.bookmarkgroups.BookmarkType +class com.vitorpamplona.amethyst.ui.navigation.routes.GeocacheTab # --- Enum constants persisted as strings -------------------------------------