fix(samples): Add Retrofit R8 full-mode keep rules to Android sample#5727
Merged
Conversation
The Android sample's release build uses R8 full mode, which strips generic signatures from classes that aren't kept. This broke Retrofit call-adapter creation for GithubAPI, crashing SecondActivity in onResume with 'Unable to create call adapter for interface retrofit2.Call'. Add the standard Retrofit R8 keep rules (Signature attributes, retrofit2.Call/Response, service interfaces) and keep the Repo response model for Gson. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📲 Install BuildsAndroid
|
romtsn
approved these changes
Jul 7, 2026
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.
Ref: JAVA-631
📜 Description
The Android sample crashes when opening
SecondActivityin a release build:The sample's release build uses R8 full mode (AGP 8+ default), which strips generic signatures from classes that aren't explicitly kept. Retrofit needs those signatures to build a call adapter for
GithubAPI.listRepos(): Call<List<Repo>>, so it fails and the activity crashes on resume.This adds the standard Retrofit R8-full-mode keep rules to
sentry-samples-android/proguard-rules.pro:Signature,InnerClasses,EnclosingMethodattributesretrofit2.Call/retrofit2.Response/kotlin.coroutines.Continuation(allow obfuscation/shrinking)Reporesponse model for Gson💡 Motivation and Context
The sample is unusable in release mode on the Tracing screen (Open Second Activity → crash). It's a missing-ProGuard-rule bug, independent of API level or SDK version.
💚 How did you test it?
Built the sample release APK with
-Pandroid.enableR8.fullMode=true, installed on an emulator, and opened Second Activity. Before: crash on resume. After:SecondActivityloads and the GitHub request succeeds (items: 30).📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
None.
#skip-changelog