'Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle'
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
Solution 1:[1]
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
Solution 2:[2]
"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: ***,
]
Solution 3:[3]
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!
Solution 4:[4]
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
Solution 5:[5]
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.
Solution 6:[6]
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.
Solution 7:[7]
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.
Solution 8:[8]
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
- check you localhost 8080 is running your browser chrome
like: localhost:8080
//----- then do this in your cmd path
D:para\Android\testing>react-native start --port=8081
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.
Solution 9:[9]
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!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Saeed |
Solution 3 | naheed.shamim |
Solution 4 | Slycreator |
Solution 5 | β.εηοιτ.βε |
Solution 6 | |
Solution 7 | Aditya Shrivastwa |
Solution 8 | |
Solution 9 | gabriellend |