React Native Android release APK crashes on cold start only when R8 minification is enabled — index.android.bundle missing at runtime
Environment
React Native 0.70 app, Android Gradle Plugin 7.2, Java 11, CI builds via GitLab Runner producing release APKs with minifyEnabled=true and shrinkResources=true; debug APKs (no minify) run OK on Pixel 5 (Android 13) and Samsung S22 (Android 12).
Symptoms
Release APK crashes immediately on cold start with an uninformative crash dialog on device; Android system log (adb logcat) shows app process killed after startup with Java runtime exceptions obfuscated. Users report 'app won't open' — no JS bundle loads. Reproducible locally when building with minify enabled.
Observations
- Unzipping the release APK shows assets/index.android.bundle is missing in the APK when minify/shrinkResources are enabled; debug APK contains the bundle. 2) Building with minifyEnabled=true but shrinkResources=false sometimes contains the bundle but still crashes. 3) Disabling R8 (minifyEnabled=false) makes release APK work. 4) ProGuard/R8 rules were default plus some custom -keep for com.example.* classes, but no rules relating to React Native packaging tasks. 5) CI logs show 'mergeAssets' and 'aapt' steps completed without errors.
Already attempted
Tried disabling shrinkResources and minify separately, added generic -keep rules for React Native packages (com.facebook.react.**), ensured bundle generation gradle task runs, verified gradle's react.gradle is applied. Rebuilt with --no-daemon and cleaned caches; results inconsistent until minifyDisabled.
Question
Why is the JS bundle not packaged in the release APK when R8/minification/shrinkResources are enabled, and how can I keep code shrinking active while ensuring a valid release APK with the bundle included and no startup crash?
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