10

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.

Anjali Neela
  • 101
  • 1
  • 1
  • 4
  • 1
    npx react-native start... and in another tab npx react-native run-android – mainak Jul 23 '20 at 12:32
  • No..I tried it again now...but the same error pops up. The image which I have attached as "metro bundler not running" is coming. Is there any way that the bundler can be displayed as normal where the dependency graph is seen? I mean the bundler is also having problem right..! So is there any solution? thank you – Anjali Neela Jul 23 '20 at 15:03
  • One thing you can do is that for this error is that you have to verify the port number on which react native is running which is by default 8081. Find the processor which is running on that port by using this command in command prompt: `netstat -an |find /i "8081" ` If any other proceesor is running on it if possible kill it and free the port. If it is some important processor like McAfee then use another port for running react native with the following command: ` react-native run-android --port=xxxx ` where xxxx is the port number which you would like react native to run on. Thank u – Anjali Neela Jul 29 '20 at 04:42

4 Answers4

6

"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: ***,  
]
Charney Kaye
  • 3,667
  • 6
  • 41
  • 54
Mahmonir Bakhtiyari
  • 546
  • 1
  • 8
  • 21
1

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.
Dharman
  • 30,962
  • 25
  • 85
  • 135
Prashant Jajal
  • 3,469
  • 5
  • 24
  • 38
0

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
piouson
  • 3,328
  • 3
  • 29
  • 29
0
  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
arjilm
  • 71
  • 2
  • 6