Skip to content

Commit 0827c61

Browse files
abdulraqeeb33AR Abdul Azeez
andauthored
fix: keep WorkManager InputMerger for R8 (AGP 9); minified demo + CI (#2589)
Co-authored-by: AR Abdul Azeez <abdul@onesignal.com>
1 parent 002efd7 commit 0827c61

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ concurrency:
77
on:
88
pull_request:
99
branches: ["**"]
10+
push:
11+
branches:
12+
- main
13+
- "*-main"
14+
workflow_dispatch:
1015

1116
env:
1217
DIFF_COVERAGE_THRESHOLD: "80"
@@ -36,8 +41,13 @@ jobs:
3641
working-directory: OneSignalSDK
3742
run: |
3843
./gradlew testDebugUnitTest --console=plain --continue
44+
- name: "[Build] Demo app (minified release)"
45+
working-directory: OneSignalSDK
46+
run: |
47+
./gradlew :app:assembleGmsRelease --console=plain
3948
- name: "[Diff Coverage] Check for bypass"
4049
id: coverage_bypass
50+
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
4151
run: |
4252
# Check if PR has Skip Coverage Check label
4353
if [ "${{ github.event_name }}" = "pull_request" ]; then
@@ -54,6 +64,7 @@ jobs:
5464
echo "bypass=false" >> $GITHUB_OUTPUT
5565
fi
5666
- name: "[Diff Coverage] Check coverage"
67+
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
5768
working-directory: OneSignalSDK
5869
run: |
5970
# Use the shared coverage check script for consistency

.github/workflows/publish-release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ jobs:
8989
run: ./gradlew assembleRelease
9090
working-directory: OneSignalSDK
9191

92+
- name: Build minified demo app (validates R8 / consumer ProGuard rules)
93+
run: ./gradlew :app:assembleGmsRelease --console=plain
94+
working-directory: OneSignalSDK
95+
9296
- name: Dry Run - Publish to Maven Local with signing
9397
working-directory: OneSignalSDK
9498
run: |

OneSignalSDK/onesignal/notifications/consumer-rules.pro

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,14 @@
5959
# Keep OneSignal WorkManager workers and constructors used for runtime instantiation.
6060
-keep class com.onesignal.notifications.internal.** extends androidx.work.ListenableWorker {
6161
public <init>(android.content.Context, androidx.work.WorkerParameters);
62-
}
62+
}
63+
64+
# WorkManager instantiates InputMerger classes via reflection (InputMerger.fromClassName).
65+
# R8 full mode (AGP 8+) strips no-arg constructors, causing:
66+
# java.lang.NoSuchMethodException: androidx.work.OverwritingInputMerger.<init>()
67+
# WM-WorkerWrapper E Could not create Input Merger androidx.work.OverwritingInputMerger
68+
# Keep all InputMerger subclasses (OverwritingInputMerger, ArrayCreatingInputMerger, etc.)
69+
-keep class * extends androidx.work.InputMerger {
70+
public <init>();
71+
}
72+

examples/demo/app/build.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ android {
5353

5454
buildTypes {
5555
release {
56-
isMinifyEnabled = false
56+
// Minify MUST be enabled to exercise R8 and validate WorkManager/ProGuard rules.
57+
// See: SDK-4185, https://github.com/OneSignal/OneSignal-Android-SDK/issues/2582
58+
isMinifyEnabled = true
59+
isShrinkResources = true
60+
signingConfig = signingConfigs.getByName("debug")
5761
proguardFiles(
5862
getDefaultProguardFile("proguard-android-optimize.txt"),
5963
"proguard-rules.pro"
@@ -66,7 +70,8 @@ android {
6670
initWith(getByName("release"))
6771
isDebuggable = false
6872
isProfileable = true
69-
isMinifyEnabled = false
73+
isMinifyEnabled = true
74+
isShrinkResources = true
7075
signingConfig = signingConfigs.getByName("debug")
7176
matchingFallbacks += listOf("release")
7277
}

examples/demo/app/proguard-rules.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@
1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
2121
#-renamesourcefileattribute SourceFile
22+
23+
# Demo-only suppression for optional OTel transitive classes.
24+
-dontwarn com.fasterxml.jackson.core.JsonFactory
25+
-dontwarn com.fasterxml.jackson.core.JsonGenerator
26+
-dontwarn com.google.auto.value.AutoValue$CopyAnnotations

0 commit comments

Comments
 (0)