Skip to content

fix: keep WorkManager InputMerger for R8 (AGP 9); minified demo + CI#2589

Merged
abdulraqeeb33 merged 4 commits intomainfrom
ar/sdk-4185-bug-push-notifications-not-displayed-with-r8minify-enabled
Mar 24, 2026
Merged

fix: keep WorkManager InputMerger for R8 (AGP 9); minified demo + CI#2589
abdulraqeeb33 merged 4 commits intomainfrom
ar/sdk-4185-bug-push-notifications-not-displayed-with-r8minify-enabled

Conversation

@abdulraqeeb33
Copy link
Copy Markdown
Contributor

Description

One Line Summary

Add consumer ProGuard rules for WorkManager InputMerger classes (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 minifyEnabled reported push notifications that enqueue WorkManager jobs but never display, even after #2585 (worker constructor keep rules). Investigation showed WorkManager failing to instantiate androidx.work.OverwritingInputMerger via reflection: NoSuchMethodException on the no-arg constructor, with WM-WorkerWrapper logging that the input merger could not be created. R8 full mode strips those constructors unless they are explicitly kept. This PR adds -keep rules for all androidx.work.InputMerger subclasses so minified apps behave the same as non-minified builds.

Linear: SDK-4185
GitHub: #2582

Scope

  • SDK: OneSignalSDK/onesignal/notifications/consumer-rules.pro only (shipped to apps via AAR consumer rules).
  • Demo: Release and profileable variants use minify + shrinkResources and debug signing so local and CI builds exercise R8; demo proguard-rules.pro adds -dontwarn for optional OTel transitive references so the minified demo links cleanly.
  • CI: Runs :app:assembleGmsRelease from OneSignalSDK so 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 mapping
  • examples/demo/app/build/outputs/mapping/gmsRelease/seeds.txt — shrinker seeds
  • examples/demo/app/build/outputs/mapping/gmsRelease/usage.txt — removed unused code

Testing

Unit testing

No unit test changes; notifications module has no new Kotlin/Java sources.

Manual testing

  • ./gradlew :app:assembleGmsRelease from OneSignalSDK (links demo app to local SDK modules) completes successfully with R8 minification.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

AR Abdul Azeez added 3 commits March 19, 2026 15:07
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
Copilot AI review requested due to automatic review settings March 24, 2026 14:47
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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 InputMerger no-arg constructors under R8 full mode.
  • Enable minifyEnabled + shrinkResources for the demo app’s release and profileable build types (signed with debug keystore).
  • Update CI to build the demo app’s minified gmsRelease variant.

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.

Comment on lines +68 to +69
# Keep all InputMerger subclasses (OverwritingInputMerger, ArrayCreatingInputMerger, etc.)
-keep class * extends androidx.work.InputMerger {
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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 {

Copilot uses AI. Check for mistakes.
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# Demo-only suppression for optional OTel transitive classes.
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

📊 Diff Coverage Report

✓ Coverage check passed (no source files changed)

📥 View workflow run

@abdulraqeeb33 abdulraqeeb33 merged commit 0827c61 into main Mar 24, 2026
7 checks passed
@abdulraqeeb33 abdulraqeeb33 deleted the ar/sdk-4185-bug-push-notifications-not-displayed-with-r8minify-enabled branch March 24, 2026 17:22
abdulraqeeb33 added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: AR Abdul Azeez <abdul@onesignal.com>
This was referenced Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants