fix(widget): keep WorkManager InputMerger so widgets render under R8 (#18)
All checks were successful
CI / ci (pull_request) Successful in 8m45s
All checks were successful
CI / ci (pull_request) Successful in 8m45s
Home-screen widgets were stuck on the Glance loading layout (a blank spinner) in the minified release build — but worked in debug. Root cause: Glance renders every widget through a WorkManager worker (androidx.glance.session.SessionWorker), and WorkManager instantiates the InputMerger reflectively from the fully-qualified class name persisted in the WorkSpec (Class.newInstance, no-arg ctor). Under R8 full mode (AGP 9 default) the unused no-arg constructor of androidx.work.OverwritingInputMerger was stripped, so WorkManager threw "OverwritingInputMerger has no zero argument constructor", the SessionWorker never ran, and provideContent never executed — leaving the widget on its initial loading layout forever. Same R8-reflection family as the v2.7.0 Room keep-rule fix. Keep the name + constructor of every androidx.work.InputMerger. Verified on-device with the releaseTest build (R8-minified): the agenda widget, which showed only a spinner before, now renders its content; the WM-InputMerger InstantiationException is gone. Closes #18. Cuts v2.7.3. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
11
app/proguard-rules.pro
vendored
11
app/proguard-rules.pro
vendored
@@ -15,3 +15,14 @@
|
||||
# Keep the generated Room database implementations fully intact.
|
||||
-keep class * extends androidx.room.RoomDatabase { *; }
|
||||
-dontwarn androidx.room.paging.**
|
||||
|
||||
# WorkManager instantiates an InputMerger reflectively (Class.newInstance) from
|
||||
# the fully-qualified class name persisted in the WorkSpec, so the class must
|
||||
# keep both its name and a no-arg constructor. Glance renders every widget
|
||||
# through a WorkManager worker (androidx.glance.session.SessionWorker) whose
|
||||
# default merger is androidx.work.OverwritingInputMerger. Under R8 full mode
|
||||
# (AGP 9 default) that unused no-arg constructor was stripped, so WorkManager
|
||||
# threw "OverwritingInputMerger has no zero argument constructor", the
|
||||
# SessionWorker never ran, and widgets were stuck on their loading layout
|
||||
# (a blank spinner) in release builds. Keep every InputMerger's name + ctor.
|
||||
-keep class * extends androidx.work.InputMerger { <init>(...); }
|
||||
|
||||
Reference in New Issue
Block a user