I am having working React Native application having version 0.38.0, when i have tried to upgrade it to 0.45.1 it is showing following error
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.cxxbridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.cxxbridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:198)
at com.facebook.react.cxxbridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:33)
at com.facebook.react.cxxbridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:216)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:994)
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:109)
at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:746)
at java.lang.Thread.run(Thread.java:761)
I have tried following solutions but it didn't work for me
SO: unable to load script from assets index.android.bundle on windows
SO: react native android failed to load JS bundle
The new version of react-native does not have an index.android.js file as an entry file, it should use the index.js file
1- Create a new folder =>
android/app/src/main/assets
2- Run this command =>
This command will create 2 files :
index.android.bundle
&index.android.bundle.meta
3- run command =>
react-native run-android
Add these lines
project.ext.react = [ entryFile: "index.js", bundleAssetName: "index.android.bundle", bundleInAlpha: true, bundleInBeta: true ]
before
apply from: "../../node_modules/react-native/react.gradle"
in build.gradleOkay. Every answers are unique depending on 'when' and 'the version' at the time the problem occur.
And honestly it is very difficult to find the right answer to make it work like 'normal' for 'today', because everything has changed and is different from the time that has been left behind.
Meaning that we don't have the file as requested in the directory assets. That's all the problem!. There is no relation to port, devices, emulator etc.
Now what we need to do is to make the file is 'exist there'. And these are some options to you can do depending on your package configuration :
In your project directory, execute :
If you already have the files in asset folder, then you can continue your project.
Check if your device is connected and ready, and run-android :
Make sure you get result like this :
Then run :
Note : Alternatively, you can create a new project again with a specified version :
react-native init ProjectName --version 0.55.4
In my case, the emulator was on airplane mode. Make sure your emulator or mobile phone can communicate with the Metro server.
To resolve Unable to load script from assets index.android.bundle - React Native follow below process :
You have to create dir assets manually in your android project or make Directory by Terminal/CMD enter mkdir android/app/src/main/assets
Go at the created Directory if that is successfully created then
run step 3 Command:
you have your missed files in the folder now you can Run your React Native project npm run android.
https://stackoverflow.com/a/53275340/9489285