Sunday, June 24, 2018

Unable to load script from assets index.android.bundle on windows - Solved

This is a general error message, you may have encountered during the react native application development. So In this tutorial we are going to provide solution to this issue.

Issue Description :
Unable to load script from assets index.android.bundle on windows
Unable to load script from assets index.android.bundle on windows



Follow the below steps to solve above issue :

Step-1 : Create "assets" folder inside your project directory 

Now create assets folder inside the project directory that is "MobileApp\android\app\src\main". You can manually create assets folder :

< OR >

you can create folder by using command as well.
Command :
mkdir android/app/src/main/assets

Step-2 : Running your React Native application

Lets run the below command to run the react native application in emulator or physical device.

  • Switch to project directory.
cd MobileApp

  • Run the below command that helps to bundle you android application project.
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

  • Run the Final step to run react native application in emulator or physical device.
react-native run-android

< OR >

Also you can combine last two command in one, In this case case you have to execute command only once.
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

< OR >

You can automate the above steps by placing them in scripts part of package.json like this:
"android-Window": "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"
If everything is set up correctly, you should see your new app running in your Android emulator shortly.






No comments:

Post a Comment