fix: keep WorkManager InputMerger for R8 (AGP 9); minified demo + CI#2589
Conversation
Add explicit consumer ProGuard keep rules for OneSignal WorkManager workers and their required constructors so minified app builds can instantiate workers and display pushes reliably. Made-with: Cursor
Remove the broad WorkerParameters keep rule and retain only the worker constructor keep rule needed for runtime instantiation, reducing minification impact on consumer apps. Made-with: Cursor
- Add consumer ProGuard rules for androidx.work.InputMerger subclasses (OverwritingInputMerger, etc.) for AGP 9 / R8 reflection. - Enable minify + shrinkResources on demo release; align profileable. - CI: assemble gmsRelease minified demo from OneSignalSDK. - Demo proguard: dontwarn for optional OTel transitive classes. SDK-4185 follow-up to #2585 / #2582. Made-with: Cursor
Keep InputMerger ProGuard rules from this branch; integrate main (linear-deployed, otel consumer-rules). CI/CD updates: push/workflow_dispatch triggers, coverage gating, minified demo in publish-release. Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
This PR addresses an AGP 9 / R8 full-mode minification issue where WorkManager can fail to instantiate InputMerger implementations via reflection, causing enqueued notification work to never display. It also updates the demo app and CI to exercise minified release builds so regressions are caught automatically.
Changes:
- Add consumer ProGuard keep rules intended to retain WorkManager
InputMergerno-arg constructors under R8 full mode. - Enable
minifyEnabled+shrinkResourcesfor the demo app’sreleaseandprofileablebuild types (signed with debug keystore). - Update CI to build the demo app’s minified
gmsReleasevariant.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
OneSignalSDK/onesignal/notifications/consumer-rules.pro |
Adds keep rules for OneSignal WorkManager workers and for InputMerger reflection instantiation. |
examples/demo/app/build.gradle.kts |
Enables minification/resource shrinking for release + profileable demo variants to validate consumer rules with R8. |
examples/demo/app/proguard-rules.pro |
Adds demo-only -dontwarn suppressions for specific missing optional classes during minified linking. |
.github/workflows/ci.yml |
Builds the minified demo release (:app:assembleGmsRelease) as part of CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Keep all InputMerger subclasses (OverwritingInputMerger, ArrayCreatingInputMerger, etc.) | ||
| -keep class * extends androidx.work.InputMerger { |
There was a problem hiding this comment.
The new consumer rule keeps all classes in the app (and all transitive deps) that extend androidx.work.InputMerger. Since this file is shipped as AAR consumer rules, this can unintentionally reduce shrinking/obfuscation for any custom InputMerger subclasses in a host app and slightly increase APK size. Consider narrowing the rule to just the WorkManager mergers that are actually instantiated by reflection in this scenario (e.g., the built-in androidx.work.*InputMerger implementations) or otherwise scoping it to the minimal set needed to fix the reported crash.
| # Keep all InputMerger subclasses (OverwritingInputMerger, ArrayCreatingInputMerger, etc.) | |
| -keep class * extends androidx.work.InputMerger { | |
| # Keep built-in WorkManager InputMerger implementations (OverwritingInputMerger, ArrayCreatingInputMerger, etc.) | |
| -keep class androidx.work.*InputMerger { |
| # hide the original source file name. | ||
| #-renamesourcefileattribute SourceFile | ||
|
|
||
| # Demo-only suppression for optional OTel transitive classes. |
There was a problem hiding this comment.
The comment says these -dontwarn rules are for "optional OTel transitive classes", but the suppressed types are Jackson core and an AutoValue inner class. To avoid confusion later, please adjust the comment to name the specific dependency/path that triggers these warnings (and why suppressing them is safe for the demo) or align the comment with the exact classes being suppressed.
| # Demo-only suppression for optional OTel transitive classes. | |
| # Demo-only suppression for Jackson core and AutoValue inner class pulled in as | |
| # optional OpenTelemetry exporter transitive deps; these classes are not used | |
| # by the demo app. |
📊 Diff Coverage Report✓ Coverage check passed (no source files changed) |
Co-authored-by: AR Abdul Azeez <abdul@onesignal.com>
Description
One Line Summary
Add consumer ProGuard rules for WorkManager
InputMergerclasses (AGP 9 / R8 follow-up), enable minified release on the demo app, and build the minified demo in CI.Details
Motivation
Customers on AGP 9 with
minifyEnabledreported push notifications that enqueue WorkManager jobs but never display, even after #2585 (worker constructor keep rules). Investigation showed WorkManager failing to instantiateandroidx.work.OverwritingInputMergervia reflection:NoSuchMethodExceptionon the no-arg constructor, withWM-WorkerWrapperlogging that the input merger could not be created. R8 full mode strips those constructors unless they are explicitly kept. This PR adds-keeprules for allandroidx.work.InputMergersubclasses so minified apps behave the same as non-minified builds.Linear: SDK-4185
GitHub: #2582
Scope
OneSignalSDK/onesignal/notifications/consumer-rules.proonly (shipped to apps via AAR consumer rules).proguard-rules.proadds-dontwarnfor optional OTel transitive references so the minified demo links cleanly.:app:assembleGmsReleasefromOneSignalSDKso minified integration is validated on every PR.No public API changes.
Other
R8 outputs for inspection after a minified build (variant
gmsRelease):examples/demo/app/build/outputs/mapping/gmsRelease/mapping.txt— obfuscation mappingexamples/demo/app/build/outputs/mapping/gmsRelease/seeds.txt— shrinker seedsexamples/demo/app/build/outputs/mapping/gmsRelease/usage.txt— removed unused codeTesting
Unit testing
No unit test changes; notifications module has no new Kotlin/Java sources.
Manual testing
./gradlew :app:assembleGmsReleasefromOneSignalSDK(links demo app to local SDK modules) completes successfully with R8 minification.Affected code checklist
Checklist
Overview
Testing
Final pass