fix(widget): Broaden work-runtime keep rule and add widget error handling

R8 full mode strips no-arg constructors from work-runtime classes accessed via

Class.newInstance() reflection (WorkDatabase_Impl, OverwritingInputMerger, etc).

Replace narrow WorkDatabase_Impl keep rule with broad androidx.work.** rule.

Also add @Keep to Hilt WidgetEntryPoint and wrap provideGlance setup in

try-catch so the widget shows an error message instead of spinning forever.
This commit is contained in:
darken
2026-03-06 18:47:46 +00:00
committed by Matthias Urhahn
parent d37c8aa3a5
commit da6a6f6ff2
2 changed files with 35 additions and 13 deletions
+4 -5
View File
@@ -1,9 +1,8 @@
-keep class eu.darken.capod.BuildConfig { *; }
-dontobfuscate
# Glance pulls work-runtime:2.7.1 room-runtime:2.2.5 as transitive deps.
# Room 2.2.5 finds WorkDatabase_Impl via Class.forName() reflection, but its
# consumer ProGuard rules don't keep _Impl classes, so R8 full mode (AGP 9+) strips it.
# Remove when Glance upgrades to Room 2.7+ (which uses RoomDatabaseConstructor instead of reflection).
# work-runtime 2.7.1 (pulled by Glance) uses Class.newInstance() reflection throughout.
# R8 full mode strips no-arg constructors not reachable by static analysis.
# Keep all constructors in the work package. Remove when Glance upgrades to work-runtime 2.10+.
# See: https://issuetracker.google.com/issues/243257364
-keep class androidx.work.impl.WorkDatabase_Impl { *; }
-keep class androidx.work.** { <init>(...); }