fix: keep gson/okhttp class names in consumer ProGuard rules#20
Merged
Conversation
A minified (R8) host app crashed at SDK init with "missing dependencies: Gson": checkRuntimeDependencies() resolves com.google.gson.Gson and okhttp3.OkHttpClient via Class.forName, and with no keep rule R8 was free to rename/strip those classes. Ship consumer keep rules (bundled in the AAR) so the reflective dependency check still resolves in minified release builds. Host apps must still declare gson/okhttp themselves since they are compileOnly, matching upstream Datadog. Add ConsumerRulesTest as a guard for the keep rules. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fiona2016
added a commit
that referenced
this pull request
Jun 10, 2026
Document the consumer ProGuard keep-rule fix (#20) that prevents the "missing dependencies: Gson" startup crash on R8-minified host apps. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A minified (R8) host app crashed at SDK init with:
It only happened in minified release builds, not debug.
Root cause
checkRuntimeDependencies()resolvescom.google.gson.Gsonandokhttp3.OkHttpClientvia
Class.forName(...). With no keep rule, R8 was free to rename/strip those classes,so the string-literal lookup failed at runtime and the SDK threw.
Fix
Ship consumer keep rules (bundled in the AAR via
consumerProguardFiles) so thereflective dependency check still resolves under R8:
Host apps must still declare gson/okhttp themselves (they are
compileOnly),matching upstream Datadog.
Adds
ConsumerRulesTestas a guard that these keeps stay present inconsumer-rules.pro.Verification
./gradlew :dd-sdk-android-core:testDebugUnitTest—ConsumerRulesTestpasses.🤖 Generated with Claude Code