Release APK contains index.android.bundle but app crashes on startup with obfuscated NoSuchMethodError after enabling R8 — ProGuard keep rules may be incomplete
Environment
React Native 0.68 app, Android release build with minifyEnabled=true and R8 active, devices tested: Moto G Power (Android 11) and Pixel 6 (Android 13); CI uses Gradle 7.1, Java 11.
Symptoms
Release builds with R8 enabled crash on app start for some users; logs (deobfuscated where possible) indicate NoSuchMethodError/NoClassDefFoundError originating from ReactNative's native modules initialization. Unobfuscated builds or builds with minification disabled run fine.
Observations
- index.android.bundle is present inside the APK assets. 2) Deobfuscated stack trace (after uploading mapping file) shows missing native method wrappers and React Native bridge classes. 3) Adding broad -keep rules for com.facebook.react.* resolves crash in one test build, but also prevents code shrinking to desired size. 4) The problematic code paths are in classes loaded via reflection or JNI registration patterns.
Already attempted
Added targeted -keep class com.facebook.react.** and -keepclassmembers for native-registered methods; rebuilt and validated on devices. Measured APK size and verified app stable in these builds. Tried to narrow keep rules but crash reappeared until a group of bridge classes were kept intact.
Question
Which R8/ProGuard keep rules are safe and minimal to prevent React Native bridge classes from being stripped while allowing most code shrinking? Is there an established minimal rule set to avoid runtime NoSuchMethodError on release builds?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags