Skip to content

ref(android): Narrow consumer keep rules to what the SDK reads - #6779

Merged
runningcode merged 3 commits into
mainfrom
no/narrow-android-keep-rules
Dec 2, 2026
Merged

runningcode merged 3 commits into
mainfrom
no/narrow-android-keep-rules

Conversation

@runningcode

@runningcode runningcode commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Narrows Android consumer keep rules to the names and members the SDK actually reads by reflection, and drops the app-wide -keepnames class * implements io.sentry.Integration.

💡 Motivation and Context

Google Play adds DEX optimization thresholds in Feb 2027, and library consumer rules count against the app. Part of #6771 (JAVA-856).

  • Replay: isMaskable() now leaves VectorPainter, ColorPainter, and BrushPainter unmasked by type instead of by class name, so no Painter needs to keep its name. Before, an app's own Painter with Vector, Color, or Brush in its name stayed unmasked; it's now masked in debug and release alike.
  • Left as-is on purpose: the enum and SentryOptions rules (hybrid SDKs depend on them), the Throwable rule, -keeppackagenames, and the exception keepnames.

💚 How did you test it?

Built the minified sentry-samples-android release with and without these changes (together with #6778) and ran the same journey on an API 36 emulator: exceptions with screenshot and view hierarchy, Timber, native capture, fragment and Compose testTag click breadcrumbs, Session Replay, and a Java crash on relaunch. Captured the envelopes locally. The events, attachments, view hierarchy tags, breadcrumbs, sdk.integrations, and the integration init logs were identical, and logcat showed no reflection failures.

R8 Configuration Analyzer on the sample: Sentry's rules keep 1,556 items instead of 1,700, and the uncompressed DEX shrinks by 6.5 KB.

📝 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Conflicts with #6778 in sentry-android-core/proguard-rules.pro and CHANGELOG.md. Whichever lands second takes both sides.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 9fb60b3.

Main concerns: reach, public contract, data sent to Sentry.

Rules that block low also fired:

  • R6: build or release configuration changed: sentry-android-core/proguard-rules.pro, sentry-android-fragment/proguard-rules.pro, sentry-android-ndk-outproc/proguard-rules.pro, sentry-android-ndk/proguard-rules.pro, sentry-android-replay/proguard-rules.pro and 2 more

This label is a hint for reviewers, not an approval.

@sentry

sentry Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@runningcode
runningcode marked this pull request as ready for review November 26, 2026 07:18
@runningcode
runningcode requested review from a team and adinauer as code owners November 26, 2026 07:18
@runningcode
runningcode requested review from markushi and romtsn and removed request for a team November 26, 2026 07:18
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 26, 2026

@0xadam-brown 0xadam-brown left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick comment; otherwise lgtm 👍

@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 26, 2026
runningcode and others added 3 commits December 2, 2026 17:01
Classes that are only checked by name now keep just their name, the
NDK entry points keep only init() and close(), replay keeps the names
of the three Painters isMaskable() leaves unmasked, LayoutNode keeps
only the reflected members, and the Compose tag elements keep only
their tag field. The app-wide Integration keepnames is dropped, since
integration names are string literals now.

Refs #6771
Refs JAVA-856

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isMaskable() left any Painter unmasked whose class name contained Vector, Color, or Brush. Once R8 renames an app's painter, that check gave different results in debug and release. Checking the three AndroidX types directly behaves the same in both, and drops their keep rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/narrow-android-keep-rules branch from 0299f5c to 9fb60b3 Compare December 2, 2026 16:03
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 2, 2026
@runningcode
runningcode merged commit b2f01d0 into main Dec 2, 2026
51 checks passed
@runningcode
runningcode deleted the no/narrow-android-keep-rules branch December 2, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants