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

Modern-Apps.git / proguard-rules.pro

proguard-rules.pro114 lines · 6.0 KiBRaw
1-dontwarn java.beans.**
2-dontobfuscate
3
4# Annotation metadata is read reflectively by Room, kotlinx.serialization and
5# protobuf-lite, so these stay repo-wide. MethodParameters is deliberately NOT
6# here: it stores a name string for every parameter of every method in the app,
7# and no app reflects on parameter names.
8-keepattributes RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,AnnotationDefault,Signature
9
10# Protobuf Lite - the generated runtime schema accesses message fields (e.g.
11# platform_) reflectively, so R8 must not strip them. Without this you get
12# "Field platform_ for ...SystemInfo not found" at runtime in release builds.
13-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
14-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
15 <fields>;
16}
17
18-keepclasseswithmembernames class * {
19 native <methods>;
20}
21
22# --- Classes that Rust resolves by literal name over JNI ---
23# The rule above only covers a class that DECLARES a native method. These are
24# looked up from Rust with FindClass/GetMethodID against a hardcoded string while
25# declaring no native members of their own, so renaming them breaks the lookup.
26# Worse, most degrade silently instead of throwing: jni_http::init just returns
27# false, and callers treat that as "no network" — maps renders blank tiles and
28# youpipe returns error envelopes, both logging a missing-dependency message that
29# points nowhere near the real cause.
30
31# library/jni-http/src/main/rust/src/lib.rs:78,121 — every .so reaches the network
32# through this one bridge, so this covers maps, youpipe, weather, ...
33# Both methods must be kept: `request` serves single range reads (archive header
34# open, sub-two-range batches) and `requestBatch` serves every tile wave of two
35# or more ranges. `requestBatch` is only referenced from Rust over JNI, so R8
36# sees no Java-side caller and strips it in release builds — which fails every
37# tile with "Method not found: requestBatch" and renders a blank map (issue 792).
38-keep class com.vayunmathur.library.network.NativeHttpBridge {
39 public static byte[] request(int, java.lang.String, byte[], byte[]);
40 public static byte[] requestBatch(java.lang.String, java.lang.String[]);
41}
42
43# maps/src/main/rust/src/lib.rs:138 — call_method(thiz, "fetchTrafficData", ...).
44# OfflineRouter itself has native methods so its name survives, but this is a
45# plain private method and its name does not.
46-keepclassmembers class com.vayunmathur.maps.util.OfflineRouter {
47 private void fetchTrafficData(double, double, double, double, int, boolean);
48}
49
50# maps/src/main/rust/src/lib.rs:234,575,765 — FindClass + new_object on these two
51# nested result types. Neither declares a native method.
52-keep class com.vayunmathur.maps.util.OfflineRouter$RawStep { <init>(...); }
53-keep class com.vayunmathur.maps.util.OfflineRouter$RawDeparture { <init>(...); }
54
55# euicc/src/main/rust/src/jni.rs:29 — call_static_method("transmitApdu", "([B)[B").
56-keep class com.vayunmathur.euicc.EuiccNative {
57 public static byte[] transmitApdu(byte[]);
58}
59
60# gRPC + okhttp + protobuf-lite (:appstore Accrescent source). grpc-okhttp is the first
61# okhttp in the repo. grpc looks up its transport/name-resolver providers via reflection and
62# META-INF/services; okhttp/okio and grpc reference optional compile-time deps (Conscrypp,
63# error-prone, javax.annotation, animal-sniffer) that are absent at runtime on Android.
64-keep class io.grpc.** { *; }
65-dontwarn io.grpc.**
66-keep class okhttp3.** { *; }
67-keep interface okhttp3.** { *; }
68-dontwarn okhttp3.**
69-keep class okio.** { *; }
70-dontwarn okio.**
71-dontwarn com.google.errorprone.annotations.**
72-dontwarn javax.annotation.**
73-dontwarn org.codehaus.mojo.animal_sniffer.**
74-dontwarn org.conscrypt.**
75# Accrescent's generated protobuf-lite messages (app.accrescent.appstore.v1, com.android.bundle)
76# are covered by the GeneratedMessageLite keep above; grpc service descriptors are under io.grpc.
77
78# JGit (org.eclipse.jgit, used by :code) is a desktop/server Java library. It references JVM
79# APIs absent on Android — JMX (java.lang.management / javax.management), GSS-API/Kerberos
80# (org.ietf.jgss), java.lang.ProcessHandle, and the SLF4J static binder — only on code paths
81# Android never hits (MBean monitoring, Negotiate HTTP auth, PID-file locks). With
82# android.enableR8.fullMode=true these dangling refs fail the build, so suppress them.
83-dontwarn java.lang.ProcessHandle
84-dontwarn java.lang.management.**
85-dontwarn javax.management.**
86-dontwarn org.ietf.jgss.**
87-dontwarn org.slf4j.impl.**
88
89# --- Room migrations — keep reflective Companion access (see SqlCipher.kt:93, FFDatabase.kt:160) ---
90-keep class * extends androidx.room3.RoomDatabase { *; }
91-keep class * implements com.vayunmathur.library.util.DatabaseMigrations { *; }
92# SqlCipher.kt:93 calls dbClass.getDeclaredField("Companion"), and dbClass is
93# always a RoomDatabase subclass — so this only has to cover those rather than
94# every class in every app. The keep above already retains all members of a
95# RoomDatabase subclass; spelling it out keeps the requirement visible if that
96# rule is ever tightened.
97-keepclassmembers class * extends androidx.room3.RoomDatabase { *** Companion; }
98-keep class androidx.room3.migration.Migration { *; }
99
100# --- Glance widgets — keep classes instantiated reflectively ---
101# Glance instantiates ActionCallbacks via
102# Class.forName(name).getDeclaredConstructor().newInstance(), and GenericWidgetWorker
103# (library/widgets Widgets.kt) does the same for GlanceAppWidget subclasses. The
104# reified generics at the call sites (actionRunCallback<FooAction>()) keep the class
105# names, but R8 sees no direct constructor call and strips the no-arg <init> — every
106# tap then dies with "NoSuchMethodException: FooAction.<init> []" and Glance logs
107# "BroadcastReceiver execution failed". Calculator's keypad widget hit exactly this:
108# taps vibrated (launcher touch feedback) but onAction never ran, so nothing typed.
109-keep class * implements androidx.glance.appwidget.action.ActionCallback {
110 public <init>();
111}
112-keep class * extends androidx.glance.appwidget.GlanceAppWidget {
113 public <init>();
114}