“Unable to load script from assets” issue appears for react-native developers. It is a setup level issue for react native app.
When we tried to run the android to a simulator device by using react-native run-android command we got the following issue:
Unable to load script from assets index.android.bundle
It was missing an assets directory inside.
android/app/src/main/ When it bundled the code, it did without the assets directory. So the bundle did not work on the device.
To solve this issue we will have to do two tasks:
- Create the assets directory
- Run the bundle for the device
Following are the setps:
Step #1: Create the assets directory
$ mkdir -p android/app/src/main/assets
Step #2: Run the bundle for the device
$ 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
Now start the android:
$ react-native run-android
The react native beginner always asks about where to start. Read about it from this artile.