-dontwarn java.beans.** # DEBT (perf score): -dontobfuscate disables name obfuscation repo-wide, so R8 # shrinking/optimization runs but renaming does not. Removing it is NOT done # here: JNI/Rust literal-name lookups, Room/serialization reflection and # Glance reflective instantiation are only partly covered by the keeps below, # and no device verification is in scope for this change. Follow-up: remove # this line per-app behind release smoke tests, starting with an app with no # Rust/JNI and no reflective instantiation, and narrow the broad keeps below # (io.grpc/okhttp in :appstore, RoomDatabase { *; }) as coverage allows. -dontobfuscate # Annotation metadata is read reflectively by Room, kotlinx.serialization and # protobuf-lite, so these stay repo-wide. MethodParameters is deliberately NOT # here: it stores a name string for every parameter of every method in the app, # and no app reflects on parameter names. -keepattributes RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,AnnotationDefault,Signature # Protobuf Lite - the generated runtime schema accesses message fields (e.g. # platform_) reflectively, so R8 must not strip them. Without this you get # "Field platform_ for ...SystemInfo not found" at runtime in release builds. -keep class * extends com.google.protobuf.GeneratedMessageLite { *; } -keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { ; } -keepclasseswithmembernames class * { native ; } # --- Classes that Rust resolves by literal name over JNI --- # The rule above only covers a class that DECLARES a native method. These are # looked up from Rust with FindClass/GetMethodID against a hardcoded string while # declaring no native members of their own, so renaming them breaks the lookup. # Worse, most degrade silently instead of throwing: jni_http::init just returns # false, and callers treat that as "no network" — maps renders blank tiles and # youpipe returns error envelopes, both logging a missing-dependency message that # points nowhere near the real cause. # library/jni-http/src/main/rust/src/lib.rs:78,121 — every .so reaches the network # through this one bridge, so this covers maps, youpipe, weather, ... # Both methods must be kept: `request` serves single range reads (archive header # open, sub-two-range batches) and `requestBatch` serves every tile wave of two # or more ranges. `requestBatch` is only referenced from Rust over JNI, so R8 # sees no Java-side caller and strips it in release builds — which fails every # tile with "Method not found: requestBatch" and renders a blank map (issue 792). -keep class com.vayunmathur.library.network.NativeHttpBridge { public static byte[] request(int, java.lang.String, byte[], byte[]); public static byte[] requestBatch(java.lang.String, java.lang.String[]); } # maps/src/main/rust/src/lib.rs:138 — call_method(thiz, "fetchTrafficData", ...). # OfflineRouter itself has native methods so its name survives, but this is a # plain private method and its name does not. -keepclassmembers class com.vayunmathur.maps.util.OfflineRouter { private void fetchTrafficData(double, double, double, double, int, boolean); } # maps/src/main/rust/src/lib.rs:234,575,765 — FindClass + new_object on these two # nested result types. Neither declares a native method. -keep class com.vayunmathur.maps.util.OfflineRouter$RawStep { (...); } -keep class com.vayunmathur.maps.util.OfflineRouter$RawDeparture { (...); } # euicc/src/main/rust/src/jni.rs:29 — call_static_method("transmitApdu", "([B)[B"). -keep class com.vayunmathur.euicc.EuiccNative { public static byte[] transmitApdu(byte[]); } # App-specific keeps live beside the app (auto-included by # common-conventions-app when /proguard-rules.pro exists): gRPC/OkHttp # keeps are in appstore/proguard-rules.pro and JGit dontwarns in # code/proguard-rules.pro. They were previously in this shared file, where # every app carried rules for libraries it does not ship. # --- Room migrations — keep reflective Companion access (see SqlCipher.kt:93, FFDatabase.kt:160) --- -keep class * extends androidx.room3.RoomDatabase { *; } -keep class * implements com.vayunmathur.library.util.DatabaseMigrations { *; } # SqlCipher.kt:93 calls dbClass.getDeclaredField("Companion"), and dbClass is # always a RoomDatabase subclass — so this only has to cover those rather than # every class in every app. The keep above already retains all members of a # RoomDatabase subclass; spelling it out keeps the requirement visible if that # rule is ever tightened. -keepclassmembers class * extends androidx.room3.RoomDatabase { *** Companion; } -keep class androidx.room3.migration.Migration { *; } # --- Glance widgets — keep classes instantiated reflectively --- # Glance instantiates ActionCallbacks via # Class.forName(name).getDeclaredConstructor().newInstance(), and GenericWidgetWorker # (library/widgets Widgets.kt) does the same for GlanceAppWidget subclasses. The # reified generics at the call sites (actionRunCallback()) keep the class # names, but R8 sees no direct constructor call and strips the no-arg — every # tap then dies with "NoSuchMethodException: FooAction. []" and Glance logs # "BroadcastReceiver execution failed". Calculator's keypad widget hit exactly this: # taps vibrated (launcher touch feedback) but onAction never ran, so nothing typed. -keep class * implements androidx.glance.appwidget.action.ActionCallback { public (); } -keep class * extends androidx.glance.appwidget.GlanceAppWidget { public (); }