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 in
If you are using Windows run the commands in the following way, or if you get an error "Cannot find entry file index.android.js"
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
1 Go to your project directory and check if this folder exists android/app/src/main/assets
index.android.bundle
and index.android.bundle.meta
2.From your root project directory do
cd android && ./gradlew clean
3.Finally, navigate back to the root directory and check if there is one single entry file calledindex.js
If there is only one file i.e. index.js then run following command 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
If there are two files i.e index.android.js and index.ios.js then run this react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
react-native run-android
You can follow the instruction mentioned on the official page to fix this issue. This issue occur on real device because the JS bundle is located on your development system and the app inside your real device is not aware of it's location.
I think you don't have yarn installed try installing it with chocolatey or something. It should be installed before creating your project (react-native init command).
No need of creating assets directory.
Reply if it doesn't work.
Edit: In the recent version of react-native they have fixed it. If you want complete freedom from this just uninstall node (For complete uninstallation Completely remove node refer this link) and reinstall node, react-native-cli then create your new project.
when I update react-native to 0.49.5, this problem appears and when I followed this Breaking changes and deprecations
it disappeared.
I have faced the same problem with a real android device.
Solution: Based on this answer by Niltoid
for Mac user: open your network preference, here you will get your local IP.