React-native: E/AndroidRuntime: FATAL EXCEPTION: create_react_context

Created on 11 Feb 2019  路  15Comments  路  Source: facebook/react-native

馃悰 Bug Report

I upgrade RN to last version ,then i want run it ,result this error.

To Reproduce

frist run commind "react-native upgrade"
then run "react-native-git-upgrade"
last run "npm install" and "react-native run-android"

Expected Behavior

I hope it worked for me.

Code Example

02-11 15:54:12.131 1017-1358/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.xx.xx, PID: 1017
java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:226)
at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:32)
at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:253)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1152)
at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943)
at java.lang.Thread.run(Thread.java:818)

Environment

React Native Environment Info:
System:
OS: macOS High Sierra 10.13.4
CPU: (8) x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
Memory: 27.22 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.6.0 - /usr/local/bin/node
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
API Levels: 22, 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.3, 25.0.0, 27.0.3, 28.0.0, 28.0.3
System Images: android-28 | Google APIs Intel x86 Atom
IDEs:
Xcode: /undefined - /usr/bin/xcodebuild
npmPackages:
react: ^16.6.3 => 16.6.3
react-native: ^0.58.3 => 0.58.3
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Bug Android Locked

Most helpful comment

I do have the same issue with react native 0.60

All 15 comments

react-native-git-upgrade has not been well supported and was recently removed. Can you try using a different upgrade process?

@hramos 馃憤 Do you know @providesModule,I upgrade RN to 0.58.4,it not work for me ,but befor it worked with RN0.38.0...

same issue
RN 0.59.8

Same issue, RN0.59.0, happens when building for release.

Same issue, RN0.59.0, happens when building for release.

check your gradle version (distributionUrl)
RN0.59.0 doesn't support gradle 5

Same issue, RN0.59.0, happens when building for release.

check your gradle version (distributionUrl)
RN0.59.0 doesn't support gradle 5

Don't upgrade gradle
Use *.jks format instead of *.keystore
Locate the app-release.apk, and install in any device

Thank you for the suggestions!

To follow up, my problem was completely different and stemmed from the fact that our CI server failed when trying to build JS bundle due to the limit of the amount of watchers reached, which resulted in the fact that the .apk did not contain the bundle and thus the create_react_context failed while trying to retrieve the package from the local server.

After I increased the number of watchers it compiled properly and the JS bundle was contained within the .apk and they lived happily ever after.

Related issue:
https://stackoverflow.com/questions/22475849/node-js-what-is-enospc-error-and-how-to-solve/32600959#32600959

image
I have the same problem and I solved it by turning Metro server off before the app was installed

I finally built a working Release

For the index.android.bundle mentioned here

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

Remove extra files broke the build (for Error: Duplicate resources)

rm -vrf android/app/src/main/res/drawable*

Run it with variant=release

react-native run-android --variant=release

My Environment

react-native info

  React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 611.33 MB / 32.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 12.3.1 - /usr/local/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5522156
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.0 => 0.59.0

Not sure I'm doing it right but at least the apk works on my Pixel 2

@ryanhanwu The error still existed after i follow you.

I do have the same issue with react native 0.60

+1

I do have the same issue with react native 0.60

Same issue on 0.60.5

System:
    OS: macOS 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-4570R CPU @ 2.70GHz
    Memory: 26.04 MB / 8.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.9.1 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
    Android SDK:
      API Levels: 25, 26, 27, 28
      Build Tools: 28.0.3, 29.0.1
      System Images: android-27 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: ^0.60.5 => 0.60.5

@ryanhanwu solution's worked perfectly, thank you!

can we help me out

10-09 12:59:23.526 7655 7694 E AndroidRuntime: FATAL EXCEPTION: create_react_context
10-09 12:59:23.526 7655 7694 E AndroidRuntime: Process: pacakgename, PID: 7655
10-09 12:59:23.526 7655 7694 E AndroidRuntime: java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
10-09 12:59:23.526 7655 7694 E AndroidRuntime: at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
10-09 12:59:23.526 7655 7694 E AndroidRuntime: at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:226)
10-09 12:59:23.526 7655 7694 E AndroidRuntime: at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:32)
10-09 12:59:23.526 7655 7694 E AndroidRuntime: at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:253)
10-09 12:59:23.526 7655 7694 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1152)
10-09 12:59:23.526 7655 7694 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123)
10-09 12:59:23.526 7655 7694 E AndroidRuntime: at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943)
10-09 12:59:23.526 7655 7694 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)

I can not release build my build was crach

React Native Environment Info:
System:
OS: macOS 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 57.74 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.6.0 - /usr/local/bin/node
Yarn: 1.19.0 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 22, 23, 25, 26, 27, 28, 29
Build Tools: 27.0.0, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0, 29.0.1, 29.0.2
System Images: android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.58.6 => 0.58.6
npmGlobalPackages:
react-native-cli: 2.0.1

Was this page helpful?
0 / 5 - 0 ratings