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

Modern-Apps.git / proguard-rules.pro

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