Skip to content

fix(samples): Add Retrofit R8 full-mode keep rules to Android sample#5727

Merged
runningcode merged 1 commit into
mainfrom
no/fix-samples-retrofit-r8
Jul 7, 2026
Merged

fix(samples): Add Retrofit R8 full-mode keep rules to Android sample#5727
runningcode merged 1 commit into
mainfrom
no/fix-samples-retrofit-r8

Conversation

@runningcode

@runningcode runningcode commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Ref: JAVA-631

📜 Description

The Android sample crashes when opening SecondActivity in a release build:

java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
    ... at SecondActivity.onResume → updateRepos → GithubAPI.service.listRepos(...)

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:

  • keep Signature, InnerClasses, EnclosingMethod attributes
  • keep retrofit2.Call / retrofit2.Response / kotlin.coroutines.Continuation (allow obfuscation/shrinking)
  • keep annotated Retrofit service interfaces
  • keep the Repo response 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: SecondActivity loads and the GitHub request succeeds (items: 30).

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

None.

#skip-changelog

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>
@sentry

sentry Bot commented Jul 6, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.47.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode runningcode marked this pull request as ready for review July 6, 2026 14:28
@linear-code

linear-code Bot commented Jul 6, 2026

Copy link
Copy Markdown

JAVA-631

@runningcode runningcode merged commit 61ba1d5 into main Jul 7, 2026
35 of 36 checks passed
@runningcode runningcode deleted the no/fix-samples-retrofit-r8 branch July 7, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants