Unable to load script from assets index.android.bundle on windows
I'm trying to run my first React Native project for first time on my device (Android 4.2.2).
And I get:
unable to load script from assets index.android.bundle
Commands that I used:
cd (project directory)
react-native start
react-native run-android
I've encountered the same issue while following the React Native tutorial (developing on Linux and targeting Android).
This issue helped me resolve the problem in following steps.
- (in project directory)
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
You can automate the above steps by placing them in scripts
part of package.json
like this:
"android-linux": "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"
Then you can just execute npm run android-linux
from your command line every time.
If You are running your application on physical device and getting this error
unable to load script from assets index.android.bundle
try running the command:
adb reverse tcp:8081 tcp:8081
It workd for Me...
I spent hours trying to figure this issue out. My problem was not specific to Windows but is specific to Android.
Accessing the development server worked locally and in the emulator's browser. The only thing that did not work was accessing the development server in the app.
Starting with Android 9.0 (API level 28), cleartext support is disabled by default.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>
See for more info: https://stackoverflow.com/a/50834600/1713216
Using npm version 4.3.0 react-native-cli version 2.01 react-native version 0.49.5
In the project directory,
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
The file name has changed from index.android.js to index.js