fix(otel): broaden R8 dontwarn for Auto Value (SDK-4207)#2607
fix(otel): broaden R8 dontwarn for Auto Value (SDK-4207)#2607abdulraqeeb33 wants to merge 2 commits intomainfrom
Conversation
Use -dontwarn com.google.auto.value.** so R8 release builds do not fail on optional annotation types referenced by OpenTelemetry (SDK-4207, #2596), including future inner types or extensions. Remove duplicate suppressions from the demo app ProGuard file so minified builds validate the library consumer-rules.pro via dependency substitution. Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
This PR fixes R8 release minification failures caused by optional OpenTelemetry sdk-logs references to Google AutoValue annotation types that are not present on consuming apps’ classpaths, by shipping broader suppressions via the com.onesignal:otel consumer ProGuard rules and removing redundant demo-app-only suppressions.
Changes:
- Broaden AutoValue suppression in
onesignal/otelconsumer rules to-dontwarn com.google.auto.value.**to cover inner/extension types. - Remove duplicate
-dontwarnentries from the demo app so minified demo builds exercise the library-provided consumer rules.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
OneSignalSDK/onesignal/otel/consumer-rules.pro |
Expands AutoValue -dontwarn to a wildcard to prevent R8 missing-class failures for optional annotation references. |
examples/demo/app/proguard-rules.pro |
Removes redundant suppressions so the demo relies on com.onesignal:otel consumer ProGuard rules during minified builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
examples/demo/app/proguard-rules.pro
Outdated
| # Optional Jackson / Auto Value suppressions for OneSignal OTel are shipped in | ||
| # com.onesignal:otel consumer-rules.pro; the minified demo relies on those (see SDK-4207 / #2596). |
There was a problem hiding this comment.
🟡 The new comment in examples/demo/app/proguard-rules.pro incorrectly states that the demo relies on com.onesignal:otel's consumer-rules.pro, when in fact otel is not a transitive dependency of the demo app at all. Future contributors may believe the demo exercises otel's ProGuard consumer rules as a regression test, when it does not; this false assumption could cause real R8 failures to go undetected.
Extended reasoning...
What the bug is: The comment added at lines 23-24 of examples/demo/app/proguard-rules.pro reads: "Optional Jackson / Auto Value suppressions for OneSignal OTel are shipped in com.onesignal:otel consumer-rules.pro; the minified demo relies on those." This claim is factually incorrect.
The code path that triggers the misunderstanding: The PR description explains that "minified demo builds exercise the library consumer-rules.pro (via OneSignalSDK/settings.gradle dependency substitution)." While dependency substitution in settings.gradle does replace com.onesignal:otel with the local :OneSignal:otel project, this substitution only applies to modules that are already requested in the dependency graph — it cannot inject otel into a build that never declared it.
Why existing code doesn't prevent it:
examples/demo/app/build.gradle.ktsdeclares onlycom.onesignal:OneSignalas a dependency.OneSignalSDK/onesignal/build.gradle(the main SDK module) exposescore,notifications,in-app-messages, andlocationasapidependencies — NOT otel.- Since otel is never in the demo's transitive dependency graph, Android Gradle Plugin never picks up otel's
consumerProguardFiles(i.e.,consumer-rules.pro) during the demo's R8 pass.
Why the demo build passes: The old dontwarn lines in proguard-rules.pro were dead code — otel classes were never on the demo's classpath, so R8 never generated warnings for them. Removing those lines is correct, but for the wrong stated reason.
Impact: The misleading comment creates a false impression that the demo's minified build acts as a regression test for otel's ProGuard consumer rules. If a future contributor adds otel as a dependency and otel's consumer-rules.pro is missing or broken, they may wrongly assume the demo would have caught it. Conversely, someone auditing the demo's ProGuard setup may waste time tracing a dependency path that doesn't exist.
Step-by-step proof:
- Open
examples/demo/app/build.gradle.kts— onlycom.onesignal:OneSignalis listed. - Open
OneSignalSDK/onesignal/build.gradle—apideps are core, notifications, in-app-messages, location. No otel. - Run
./gradlew :app:dependenciesin the demo — otel does not appear in the dependency tree. - Because otel is absent, AGP never merges otel's
consumerProguardFilesinto the demo's R8 config. - Conclusion: the comment's claim that "the minified demo relies on those" rules is incorrect.
How to fix it: Replace the comment with an accurate statement, e.g.: "The old dontwarn lines above were removed because otel classes are not on the demo classpath (otel is not a transitive dep of com.onesignal:OneSignal). If otel is ever added to the demo, consumer-rules.pro in com.onesignal:otel will supply the suppressions automatically."
Address review feedback: otel is transitive via core (implementation), not injected by settings substitution; note older SDKs without otel. Made-with: Cursor
|
@claude[agent] review |
Reviewed the PR. The changes look good: b34c4db: Broadened df3e76c: Enhanced documentation explaining that AGP merges otel's consumer-rules.pro when core pulls it as an implementation dependency. The wildcard approach is maintainable and correctly addresses SDK-4207. CodeQL and lint checks passed. |
Summary
Addresses R8 release failures where
opentelemetry-sdk-logsreferences Google Auto Value annotation types that are not on the app classpath (SDK-4207, GitHub #2596).Changes
OneSignalSDK/onesignal/otel/consumer-rules.pro: Replace three specific-dontwarnlines with-dontwarn com.google.auto.value.**so inner types and extensions (e.g.Memoized) are covered without follow-up tickets.examples/demo/app/proguard-rules.pro: Remove duplicate suppressions so minified demo builds exercise the libraryconsumer-rules.pro(viaOneSignalSDK/settings.gradledependency substitution).Verification
./gradlew :app:minifyGmsReleaseWithR8 :app:minifyHuaweiReleaseWithR8fromOneSignalSDK/(PASS).Made with Cursor