React-native-navigation: [V3][Android] FATAL EXCEPTION: create_react_context

Created on 30 Oct 2019  Â·  24Comments  Â·  Source: wix/react-native-navigation

Issue Description

I'm migrating an existing application from RN 0.59.9 and RNN 2.26.5 to RN 0.61.3 and RNN 3.3.0. I'm doing it from a fresh npx react-native init project.

For now, I'm only working with Android.

When launching the app with npx react-native run-android, the app installs correctly on the device but it instantly crashes with:

2019-10-30 21:35:21.135 17097-17143/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: my.app, PID: 17097
    java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run '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:227)
        at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:28)
        at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:261)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1175)
        at com.facebook.react.ReactInstanceManager.access$1000(ReactInstanceManager.java:125)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:951)```

So... what is the problem?

Steps to Reproduce / Code Snippets / Screenshots

You should be able to reproduce the same issue with setting up a new RNN project with RN 0.61.3 and RNN 3.3.0.

You can use the basic app from the documentation.

import { Navigation } from "react-native-navigation";
import App from "./App";

Navigation.registerComponent(`navigation.playground.WelcomeScreen`, () => App);

Navigation.events().registerAppLaunchedListener(() => {
  Navigation.setRoot({
    root: {
      component: {
        name: "navigation.playground.WelcomeScreen"
      }
    }
  });
});

Run npx react-native run-android and you should get the crash when the app starts///


Environment

  • React Native Navigation version: 3.3.0
  • React Native version: 0.61.3
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): device, debug mode, Android 9

Most helpful comment

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.

Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

All 24 comments

I do not understand this issue. I'm having it on a fresh and empty project. Anyone help?

Could it be due to the new react native cli (@react-native-community/cli) ? Are you guys using it or are you still using the legacy (globally installed) one?

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.

Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

@zabojad How did you find out that this was causing the problem?

@danielwinkler I did setup my entire project from scratch several times and finally ended up comparing my RNN setup with the one from some example like this one.

And eventually found ou that the only difference was this... Quite a painful debug...

Thanks for letting me know.

I guess you saved me some precious hours going through the same troubles on
this stupid bug!

Thanks!

Thomas Fétiveau notifications@github.com schrieb am Di., 3. Dez. 2019,
13:41:

@danielwinkler https://github.com/danielwinkler I did setup my entire
project from scratch several times and finally ended up comparing my RNN
setup with the one from some example like this one
https://github.com/alexn29/react-native-navigation-v3.

And eventually found ou that the only difference was this... Quite a
painful debug...

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/wix/react-native-navigation/issues/5617?email_source=notifications&email_token=AAA37CB34G26QKQI5JP5TATQWZHVZA5CNFSM4JG7K7QKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFZHQPA#issuecomment-561150012,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAA37CDYCRZMV24FQIYAKQTQWZHVZANCNFSM4JG7K7QA
.

@zabojad Thank you so much for this. I am eternally grateful.

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.

Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

OMG you saved me!! can't thank you enough

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.

Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

You saved my ass thanks a lot... but i'm wondering by removing this import... do you know possible consequences?

but i'm wondering by removing this import... do you know possible consequences?

@TakaKeiji After months running without that import, I can safely say that I have not observed any bad consequence from it...

@zabojad: many thanks!

@zabojad: Thanks!

OMG!! I spent 4 hours debugging this issue
@zabojad THANK YOU!!!

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.

Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

OMG!! WORK PERFECT! I tried all way and spent 4h for this issue

Thanks for solving this bug. You are the real hero.

but i'm wondering by removing this import... do you know possible consequences?

@TakaKeiji After months running without that import, I can safely say that I have not observed any bad consequence from it...

I was led to put it when I got some error with android studio regarding debug build, it was because I was trying to clone an existing app of my company with the same things but different names.

Thank you very much.


Screenshot from 2020-08-27 23-32-06

in MainApplication.java added import com.facebook.react.BuildConfig; then also I am facing same issue :(

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.

Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

OK, after a good night of sleep, I've found why I was having this issue.
In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.
Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

OMG!! WORK PERFECT! I tried all way and spent 4h for this issue

it saved me too

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.

Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

Saved me hours. Thanks.

Turns out I imported the wrong BuildConfig from Import Suggestions while adding a library

image

OK, after a good night of sleep, I've found why I was having this issue.
In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.
Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

You saved my ass thanks a lot... but i'm wondering by removing this import... do you know possible consequences?

Yes , I had same problem and i removed
import com.facebook.react.BuildConfig;
and it worked for me

If that solution doesn't work (import com.facebook.react.BuildConfig;), try this in /awesomeProject/android: ./gradlew clean

Worked for me too. It's worrying that no-one has a clue why it would create a broken app. It's like we're increasingly using tools that only maybe one or two engineers at Google understand (since they've created them, and assuming they remember what they've done) but that's about it. The rest of us we're doomed to randomly add or remove lines of code without having a clue what we're doing.

Thankss alottt..!! Removing the same worked for me t0o... Genious.!! 💯

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

Thaaanks, brudda. 3 FKNHOURS.

OK, after a good night of sleep, I've found why I was having this issue.

In the MainApplication.java, I had this:

import com.facebook.react.BuildConfig;

For a reason I don't yet understand, this was compiling correctly but was also provoking this issue.

Gosh! It was painful. If anyone could explain to me the error I was having, I would be very glad.

thanks guy.

Was this page helpful?
0 / 5 - 0 ratings