ueno-llc / react-native-starter

Professional react-native starter kit with everything you'll ever need to deploy rock solid apps
https://ueno-llc.github.io/react-native-starter
MIT License
574 stars 90 forks source link

Unable to load script from assets 'index.android.bundle' #209

Closed pcg92 closed 5 years ago

pcg92 commented 5 years ago

Im running the command react-native run-android deploying in a Xioami A1 with android 9 in mac os. The full error log is,,

    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:216)
        at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:32)
        at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:243)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1116)
        at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:117)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:916)
        at java.lang.Thread.run(Thread.java:764)

Im trying to fix it reading from stackoverflow, because it seems a common problem

jeremybarbet commented 5 years ago

Is it working on emulator?

We had the same issue (afaik) on iOS and we wrote the documentation for that: https://ueno-llc.github.io/react-native-starter/#/DEBUGGING?id=troubleshooting

As you can see the documentation is not complete for Android. My 2ct would be, that the bundle file doesn't exist and isn't include into the app apk.

I could take a look at it later, if you have any more informations feel free to share them here

pcg92 commented 5 years ago

Yes, its running fine on emulator (tested with android 6 and android 8). And is getting fail on Xiaomi a1 (tested on android 8 and android 9).

pcg92 commented 5 years ago

Working on devices using this commands:

mkdir android\app\src\main\assets\

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

react-native run-android

Is possible to use this boilerplate using hot realoding?

jeremybarbet commented 5 years ago

Nice one, I'll update the doc later with it.

Unfortunately using react-native bundle will create a static version of the javascript code into the apk of the app. In short, you have to execute the command each time you change something to see the changes on your device.

Eventhough, the cause of the initial issue could be your network that doesn't allow your localhost ip. Make sure both you are on the same wifi network and you have access to your computer through your phone.

birkir commented 5 years ago

This is fixed in the latest version 3.0.0