Unable to load script. Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release

Viewed 6998

I created a new project with react-native init . I am using react-native with the following:"react": "16.13.1","react-native": "0.63.2".

When i am trying to run the app with react-native run-android command it shows build successful in the terminal but nothing appears in my metro bundler(I am attaching the image of it) and my emulator shows the 'Unable to load script' issue. Unable to load script

If I press 'R' to reload the app in node(bundler) it says there is no device attached to it but my emulator is running. I encountered the same problem with personal device also. metro bundler not running

I also tried by creating the assets folder in android/app/src/main/assets and run the below 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.

With this only once the app gets displayed on the emulator and when I make changes in the App.js file and save it there is no change in the emulator.

If I reload the error "Could not connect to the development server" pops up. could not connect to development server Even tried the adb reverse and changing 'dev' options to local host and port 8081, but it was not useful. (If there is any specific path where I should try the above steps please mention).

What is that I have done wrong?

Can anyone help please.

P.S.: I am using a windows 10 machine.

Thank you.

4 Answers

"react-native": "0.64.1",

I used other solution but I've resolved this issue in other way. I resolved it by changing bundleInDebug: true, in project.ext.react in android > app > build.gradle.

project.ext.react = [
bundleInDebug: true,
enableHermes: ***,  

]

I am also facing this issue and I try the below method to fix the issue.

  1. for start the npm server use npx react-native start
  2. in another tab npx react-native run-android for run the application.

Many devs have different environment setup and this complicates the solution.

I'm working on Windows with WSL2. Initially, I followed this react-native setup guide with no problems but later encountered this error, not sure why.

After many hours of searching and trying most of the answers from this duplicate question, among others, I had no luck.

Eventually, all I had to do from WSL2 was pass the host option to react-native start in order to connect to the adb server running on Windows.

yarn start --host 127.0.0.1
# or npx react-native start --host 127.0.0.1
  1. I got this issue, I solved with close the app form emulator or if you use android or iphone device you can uninstall the app.
  2. start again npm server use npx react-native start
  3. reinstall app use npx react-native run-android
Related