Skip to content

Commit 9b709b9

Browse files
committed
perf(r8): keep exception names without keeping every exception
-keep public class * extends java.lang.Throwable kept 972 classes whole. Only their names are load-bearing: the Coinbase onramp traces send `it::class.simpleName` as `errorType`, and Events.kt does the same for analytics. Those have become plain strings by the time they leave the device, so the Bugsnag mapping upload cannot repair them, which is why the rule cannot simply be deleted. Nothing reads the members, and an exception nothing constructs need not survive, so -keepnames is the rule that matches the requirement. Release R8 drops 341 classes and 455 members, and DEX falls 72,628 bytes (16,101,032 -> 16,028,404). The dropped classes are what the old rule was propping up: AddReactionError and its six subclasses go, because ChatMessagingService.addReaction has no caller outside tests and R8 had already shrunk it in both builds. CoinbaseOnRampApiError and GetJwtError subclass names are unchanged in the mapping. Also corrects two comments against what the code does. The AppRoute rule is not for analytics: annotatedEntry derives each screen's root test tag from the route's simple name via NavMetadata.screenRootTag, so obfuscating those renames the resource-ids the UI tests address. The com.kik.scan wildcard is load-bearing for JNI, which constructs those classes by name from C++ and reads their backing fields through GetFieldID.
1 parent 7b22251 commit 9b709b9

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎apps/flipcash/app/proguard-rules.pro‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Preserve source file names and line numbers for stack traces (call site tracking, Bugsnag)
22
-keepattributes SourceFile,LineNumberTable
33

4-
# Keep AppRoute class names for analytics screen tracking
4+
# Keep AppRoute class names. `annotatedEntry` derives each screen's root test tag
5+
# from the route's simple name (NavMetadata.screenRootTag), so obfuscating these
6+
# renames every screen-root resource-id the UI tests address.
57
-keepnames class com.flipcash.app.core.AppRoute
68
-keepnames class com.flipcash.app.core.AppRoute$**
79

@@ -15,7 +17,11 @@
1517
-keep class * extends io.grpc.stub.AbstractStub { *; }
1618
-keep class * implements io.grpc.BindableService { *; }
1719

18-
# Keep our scan classes that interact with native
20+
# Keep our scan classes that interact with native. The scanner's JNI constructs
21+
# these from C++ by name (FindClass("com/kik/scan/UsernameKikCode"), GetMethodID
22+
# for <init>) and reads their backing fields directly (GetFieldID for "_username",
23+
# "nativePtr"), none of which AGP's default native-methods rule covers. Five
24+
# classes, so the wildcard costs little.
1925
-keep class com.kik.scan.** { *; }
2026

2127
-assumenosideeffects class android.util.Log {
@@ -26,4 +32,10 @@
2632
public static int e(...);
2733
}
2834

29-
-keep public class * extends java.lang.Throwable
35+
# Error telemetry reads exception names at runtime — Coinbase onramp traces send
36+
# `it::class.simpleName` as `errorType`, and Events.kt does the same for analytics.
37+
# Those are plain strings by the time they leave the device, so the Bugsnag mapping
38+
# upload cannot repair them; the names have to survive obfuscation. Nothing reads
39+
# the members, and an exception nothing throws need not survive, so this is
40+
# -keepnames rather than a full keep.
41+
-keepnames public class * extends java.lang.Throwable

0 commit comments

Comments
 (0)