Conversation
Gson versions below 2.11.0 do not ship consumer ProGuard/R8 rules. With R8 full mode (default since AGP 8), the generic signature of the anonymous TypeToken subclass used when decoding a JWT is stripped in minified builds, and constructing a JWT throws "java.lang.RuntimeException: Missing type parameter." at runtime. Gson bundles the required keep rules since 2.11.0, so consuming apps no longer need to add them manually.
Member
|
Hi @solevic , thanks for raising this PR. We will review and get back on this |
Author
|
It seems I missed that the latest 2.1.0 release removed |
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.
Changes
Bumps Gson from 2.8.9 to 2.14.0.
Gson versions below 2.11.0 do not ship consumer ProGuard/R8 rules. With R8 full mode (the default since AGP 8), the generic signature of the anonymous
TypeTokensubclass used byJWTParseris stripped in minified builds, and constructing aJWTcrashes at runtime with:Since 2.11.0, Gson bundles the required keep rules in its artifact (
META-INF/proguard/gson.pro), so consuming apps get them automatically and no longer need to copy them into their own ProGuard configuration. This resolves the request in #72 the way the R8 team recommended there (#72 (comment)): upgrading Gson rather than duplicating its rules as consumer rules in this library.No public API changes.
Note on minimum Android API level: Gson 2.11.0+ requires API level 21 (and 2.15.0+ requires 24, which is why this PR targets 2.14.0 — the newest release still supporting 21). This library currently declares
minSdkVersion 15, so the effective minimum for consumers becomes API 21. Since the R8 rules were introduced in the same Gson release that raised the requirement, any version that fixes this crash implies API 21+. Happy to also bump the declaredminSdkVersionto 21 in this PR if you prefer it explicit.References
Testing
./gradlew :jwtdecode:testDebugUnitTestpasses: 93 tests, 0 failures, 0 skipped.Verified in a consuming app: a minified (R8 full mode) release build crashed with "Missing type parameter." when decoding an ID token on Gson 2.8.9 without manual keep rules, and works with Gson 2.11+ rules present.
This change adds test coverage — dependency bump only; the existing suite covers the affected paths
This change has been tested on the latest version of the platform/language or why not
Checklist