Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / proguard-rules.pro

proguard-rules.pro99 lines · 5.5 KiBRaw
1-dontwarn java.beans.**
2# DEBT (perf score): -dontobfuscate disables name obfuscation repo-wide, so R8
3# shrinking/optimization runs but renaming does not. Removing it is NOT done
4# here: JNI/Rust literal-name lookups, Room/serialization reflection and
5# Glance reflective instantiation are only partly covered by the keeps below,
6# and no device verification is in scope for this change. Follow-up: remove
7# this line per-app behind release smoke tests, starting with an app with no
8# Rust/JNI and no reflective instantiation, and narrow the broad keeps below
9# (io.grpc/okhttp in :appstore, RoomDatabase { *; }) as coverage allows.
10-dontobfuscate
11
12# Annotation metadata is read reflectively by Room, kotlinx.serialization and
13# protobuf-lite, so these stay repo-wide. MethodParameters is deliberately NOT
14# here: it stores a name string for every parameter of every method in the app,
15# and no app reflects on parameter names.
16-keepattributes RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,AnnotationDefault,Signature
17
18# Protobuf Lite - the generated runtime schema accesses message fields (e.g.
19# platform_) reflectively, so R8 must not strip them. Without this you get
20# "Field platform_ for ...SystemInfo not found" at runtime in release builds.
21-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
22-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
23 <fields>;
24}
25
26-keepclasseswithmembernames class * {
27 native <methods>;
28}
29
30# --- Classes that Rust resolves by literal name over JNI ---
31# The rule above only covers a class that DECLARES a native method. These are
32# looked up from Rust with FindClass/GetMethodID against a hardcoded string while
33# declaring no native members of their own, so renaming them breaks the lookup.
34# Worse, most degrade silently instead of throwing: jni_http::init just returns
35# false, and callers treat that as "no network" — maps renders blank tiles and
36# youpipe returns error envelopes, both logging a missing-dependency message that
37# points nowhere near the real cause.
38
39# library/jni-http/src/main/rust/src/lib.rs:78,121 — every .so reaches the network
40# through this one bridge, so this covers maps, youpipe, weather, ...
41# Both methods must be kept: `request` serves single range reads (archive header
42# open, sub-two-range batches) and `requestBatch` serves every tile wave of two
43# or more ranges. `requestBatch` is only referenced from Rust over JNI, so R8
44# sees no Java-side caller and strips it in release builds — which fails every
45# tile with "Method not found: requestBatch" and renders a blank map (issue 792).
46-keep class com.vayunmathur.library.network.NativeHttpBridge {
47 public static byte[] request(int, java.lang.String, byte[], byte[]);
48 public static byte[] requestBatch(java.lang.String, java.lang.String[]);
49}
50
51# maps/src/main/rust/src/lib.rs:138 — call_method(thiz, "fetchTrafficData", ...).
52# OfflineRouter itself has native methods so its name survives, but this is a
53# plain private method and its name does not.
54-keepclassmembers class com.vayunmathur.maps.util.OfflineRouter {
55 private void fetchTrafficData(double, double, double, double, int, boolean);
56}
57
58# maps/src/main/rust/src/lib.rs:234,575,765 — FindClass + new_object on these two
59# nested result types. Neither declares a native method.
60-keep class com.vayunmathur.maps.util.OfflineRouter$RawStep { <init>(...); }
61-keep class com.vayunmathur.maps.util.OfflineRouter$RawDeparture { <init>(...); }
62
63# euicc/src/main/rust/src/jni.rs:29 — call_static_method("transmitApdu", "([B)[B").
64-keep class com.vayunmathur.euicc.EuiccNative {
65 public static byte[] transmitApdu(byte[]);
66}
67
68# App-specific keeps live beside the app (auto-included by
69# common-conventions-app when <app>/proguard-rules.pro exists): gRPC/OkHttp
70# keeps are in appstore/proguard-rules.pro and JGit dontwarns in
71# code/proguard-rules.pro. They were previously in this shared file, where
72# every app carried rules for libraries it does not ship.
73
74# --- Room migrations — keep reflective Companion access (see SqlCipher.kt:93, FFDatabase.kt:160) ---
75-keep class * extends androidx.room3.RoomDatabase { *; }
76-keep class * implements com.vayunmathur.library.util.DatabaseMigrations { *; }
77# SqlCipher.kt:93 calls dbClass.getDeclaredField("Companion"), and dbClass is
78# always a RoomDatabase subclass — so this only has to cover those rather than
79# every class in every app. The keep above already retains all members of a
80# RoomDatabase subclass; spelling it out keeps the requirement visible if that
81# rule is ever tightened.
82-keepclassmembers class * extends androidx.room3.RoomDatabase { *** Companion; }
83-keep class androidx.room3.migration.Migration { *; }
84
85# --- Glance widgets — keep classes instantiated reflectively ---
86# Glance instantiates ActionCallbacks via
87# Class.forName(name).getDeclaredConstructor().newInstance(), and GenericWidgetWorker
88# (library/widgets Widgets.kt) does the same for GlanceAppWidget subclasses. The
89# reified generics at the call sites (actionRunCallback<FooAction>()) keep the class
90# names, but R8 sees no direct constructor call and strips the no-arg <init> — every
91# tap then dies with "NoSuchMethodException: FooAction.<init> []" and Glance logs
92# "BroadcastReceiver execution failed". Calculator's keypad widget hit exactly this:
93# taps vibrated (launcher touch feedback) but onAction never ran, so nothing typed.
94-keep class * implements androidx.glance.appwidget.action.ActionCallback {
95 public <init>();
96}
97-keep class * extends androidx.glance.appwidget.GlanceAppWidget {
98 public <init>();
99}