7

Running my project in android studio I get that error, I just installed everything and I followed everything step by step, I'm using genymotion as an emulator, and use react-native start from the root, check port 8081, disable instant run, everything which is the following link

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

EdChum
  • 376,765
  • 198
  • 813
  • 562
kuater
  • 71
  • 1
  • 1
  • 2
  • I had the same issue , this link removed my problem : https://stackoverflow.com/questions/55441230/unable-to-load-script-make-sure-you-are-either-running-a-metro-server-or-that-yo/59022921#59022921 – Abolfazl Roshanzamir Nov 24 '19 at 22:11

9 Answers9

12

First of all make sure you have started the bundler using this command in root directory:

npm start 

or

react-native start

If doesn't work add assets folder manually in the following directory

android/app/src/main/{assets}

After that rename index.android.js to index.js then use the 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

Now you can create your apk:

react-native run-android
Saeed
  • 3,294
  • 5
  • 35
  • 52
  • this lik can be helpfull : https://stackoverflow.com/questions/55441230/unable-to-load-script-make-sure-you-are-either-running-a-metro-server-or-that-yo/59022921#59022921 – Abolfazl Roshanzamir Nov 24 '19 at 22:12
7

"react-native": "0.64.1",

I've resolved this problem with changing bundleInDebug: true, in project.ext.react in android > app > build.gradle.

project.ext.react = [
bundleInDebug: true,
enableHermes: ***,  
]
Saeed
  • 3,294
  • 5
  • 35
  • 52
Mahmonir Bakhtiyari
  • 546
  • 1
  • 8
  • 21
  • That's it. But is it the correct way of resolving this issue? I mean the name 'bundleInDebug' seems to be related to the debugging mode! – Hossein Abedi Jan 26 '22 at 05:31
3

For anyone that the above didn't help, I run:

adb devices

This should give you an output similar to this:

List of devices attached
98XAY181GQ  device

The numbers/letters will be different for you. Then run the following command, replacing the word "device" with the string of numbers/letters that was printed out with the previous command:

adb -s device reverse tcp:8081 tcp:8081

Then I re-run the emulator in Android studio and it works. Hope this helps someone!

gabriellend
  • 265
  • 2
  • 12
2

I resolved this issue as below

  • Changed the directory to <app_name>
  • run command react-native start
  • Open Another tab in terminal
  • run command react-native run-android

Whenever we save the files, it will be automatically update in device. No need to call run app again and again.

I am using a physical device for running the app.

Sonia John Kavery
  • 2,099
  • 2
  • 20
  • 36
2

This usually happens in Android. To correct this, you have to change the bundle Location.

By default: it's set to localhost:8081.

For Android, you need to update to your local IP address appended with port: ip-address:8081. like xxx.xxx.x.x:8081

in Mac, you can find your Local IP address under System Preference>Network. This worked for me!

naheed.shamim
  • 340
  • 2
  • 11
2

I was having this issue with react-native-cli: 2.0.1 and react-native: 0.62.2

Run npm start in one terminal and in another terminal Run react-native run-android

Slycreator
  • 1,144
  • 11
  • 18
1

I also faced this problem. But couldn't find a best solution.

But after I turning off the airplane mode in the android emulator and turn on wifi, the app runs without an error.

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Ish
  • 113
  • 7
0

In my case , I was making a mistake in build.gradle file. you can change your targetSdkVersion from 28 to 27, minSdkVersion to 21. then you can clean your gradlew and then run react-native run-android.

0

You can check your Metro server is on or not..?

do the following command in your cmd path on your server

open two cmd window do 2nd point and 3rd point another cmd window

  1. check you localhost 8080 is running your browser chrome

like: localhost:8080

//----- then do this in your cmd path

  1. D:para\Android\testing>react-native start --port=8081

  2. D:para\Android\testing>react-native run-android --no-jetifier

That's it... check your mobile or emulator now show welcome to react...

Thank you.