Narrow and clean up Android consumer keep rules

Aperta
#6,771 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@runningcode ci sta già lavorando.

Dal 25/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Android Platform: Java

Google Play is adding DEX shrinking, optimization, and obfuscation thresholds for apps in Feb 2027, and consumer keep rules shipped by libraries count against the app (Android guidance). An audit of the consumer rules on main found rules that are dead, broader than the code needs, or app-wide. Nothing below was verified with a minified build yet.

No effect / redundant

  • sentry-android-core/proguard-rules.pro:57-61: -keepnames for io.sentry.android.okhttp.SentryOkHttpInterceptor (module no longer exists), SentryApolloInterceptor, SentryApollo3HttpInterceptor, SentryNavigationListener. Nothing looks these up by name; they register hardcoded integration names.
  • sentry-android-core/proguard-rules.pro:63-64: -keepnames for ScreenshotEventProcessor / ViewHierarchyEventProcessor. No name lookup in this repo; React Native references them directly.
  • sentry-android-ndk/proguard-rules.pro:7: -keep class io.sentry.protocol.DebugImage { *; }. sentry-native's JNI uses io/sentry/ndk/DebugImage.
  • sentry-android-ndk/proguard-rules.pro:10: native <methods> rule. The module has no native methods, and sentry-native-ndk ships the same rule for io.sentry.ndk.**.
  • sentry-compose/proguard-rules.pro:8-10: LayoutNode.layoutDelegate keep; the field isn't referenced.
  • sentry-android-replay/proguard-rules.pro:13-14: FillElement keepnames/dontwarn; the class isn't referenced.
  • -keepattributes LineNumberTable,SourceFile is repeated in fragment, navigation, navigation3, ndk, replay, sqlite, timber, compose, launchdarkly-android, and sentry-okhttp's META-INF; sentry-android-core already sets it. The navigation, navigation3, launchdarkly-android, and okhttp files contain nothing else.
  • sentry-android/proguard-rules.pro is empty. sentry-spotlight/proguard-rules.pro is never packaged (JVM jar, no consumerProguardFiles).

Broader than needed

  • sentry-android-core/proguard-rules.pro:15: -keepclassmembers enum io.sentry.** { *; } was a workaround for an R8 bug in AGP 7.3/7.4 pre-releases (getsentry/sentry-java#2094). It pins every member of every io.sentry enum, including hybrid SDK packages, and blocks enum unboxing.
  • :68: -keep class * extends io.sentry.SentryOptions { *; } was added for reflective instantiation (getsentry/sentry-java#2696). Android now uses SentryAndroidOptionsContainer, and the NDK JNI uses NdkOptions. Only the class name is still read (Sentry.java:311).
  • :49: -keepnames class * implements io.sentry.Integration applies app-wide, including app-defined integrations. It was added when integration names came from class names (getsentry/sentry-java#2592); they are now string literals. The Replay, Distribution, and Spotlight keepnames are still needed for presence checks.
  • sentry-android-core:4-10, sentry-android-fragment:4, sentry-android-timber:4, sentry-compose:4-5: -keep class X { <init>(...); } / { *; } on classes that are only checked by name and then instantiated directly. DefaultLifecycleObserver isn't looked up by name at all.
  • sentry-android-ndk:4, sentry-android-ndk-outproc:4: SentryNdk { *; } / SentryNdkOutproc { *; }. Reflection only calls init(...) and close().
  • sentry-android-replay:7: -keepnames class * extends Painter is app-wide, but isMaskable() only checks for Vector/Color/Brush painters and masks anything else. :33 uses -keep on LayoutNode where only the listed members are needed.
  • sentry-compose:17-18: TestTagElement { *; } and SentryTagModifierNodeElement { *; }; only the tag field is read.

App-wide rules worth measuring

  • sentry-android-core:46: -keep,allowshrinking,allowobfuscation class * extends java.lang.Throwable (getsentry/sentry-java#5881) disables optimization for every Throwable in the app.
  • :18: -keeppackagenames io.sentry.** blocks repackaging for all SDK and hybrid SDK classes. It exists for the startsWith("io.sentry.") frame filter in SentryStackTraceFactory.
  • keepnames on SentryHttpClientException, ApplicationNotResponding, and SentryApollo3ClientException exist for readable issue titles, which mapping-based retrace already provides.

Hybrid SDK coupling
Unity reaches SentryAndroidOptions members by name, and .NET reaches enum constants through bindings, and both currently rely on the enum and SentryOptions rules above. Narrowing those needs the hybrid SDKs to ship their own keeps first. Hybrid SDK tickets: getsentry/sentry-unreal#1732, getsentry/sentry-unity#2964, getsentry/sentry-dotnet#6017, getsentry/sentry-dart#4225, getsentry/sentry-godot#1130.

via no.

--

View Session [Sentry]

Lingua principale
Kotlin
Stelle
1.4k
Fork
483
Merge medio
2g 54m
PR unite (30g)
207

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/sentry-java

Tutte le issue di getsentry/sentry-java

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.