Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native crash release build - FATAL EXCEPTION: create_react_context

Tags:

react-native

There is no problem in the development environment, but when I get the release build, the app crashes. (Android) I created a new project (v0.68.2), I didn't make any changes, the room crashed in the same way.

npx react-native run-android --variant=release
FATAL EXCEPTION: create_react_context

java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.

FATAL EXCEPTION: create_react_context
Process: com.testreleasebuild, PID: 8291
java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
    at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
    at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:248)
    at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29)
    at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:277)
    at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1422)
    at com.facebook.react.ReactInstanceManager.access$1200(ReactInstanceManager.java:138)
    at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1111)
    at java.lang.Thread.run(Thread.java:923)
like image 728
Blogger Klik Avatar asked Apr 21 '26 07:04

Blogger Klik


2 Answers

For my case, after upgrade my react-native project from version 0.69.x to 0.70.x. The Android debug build should work but release build got same issue. Change to use Android Gradle plugin 7.2.2 help me resolved this.

android/build.gradle

classpath 'com.android.tools.build:gradle:7.2.2'
like image 52
Cuong Lam Avatar answered Apr 25 '26 05:04

Cuong Lam


The Android Gradle Plugin version was 7.0.4 when the project was first created. Android Studio version asked me to upgrade to 7.2.1, so I upgraded. It worked when I downgraded the version to 7.0.4.

android>build.gradle

classpath('com.android.tools.build:gradle:7.0.4')
like image 44
Blogger Klik Avatar answered Apr 25 '26 04:04

Blogger Klik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!