react-native: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
React Native version:
Steps To Reproduce
Describe what you expected to happen:
Snack, code example, screenshot, or link to a repository:
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 32 (1 by maintainers)
I have the same issue after upgrading from react-native 0.61.5 to 0.63.2.
npx react-native run-android
andyarn start
in a separate terminal window.npx react-native run-android --variant=Release
.npx react-native run-android --variant=Staging
. When running from Android Studio it logs the ☝️ error:These are the
buildTypes
settings in myandroid/app/build.gradle
(working fine for previous versions of react-native):Please help! All the “solutions” I found so far were either suggesting to start a Metro Instance, or adding an
assets
folder (which already exists in my project), or running a three-lines-long bundle command – but surely there must be a better way!?Update: Adding
bundleInStaging: true
to myapp/build.gradle
as suggested in this answer solved this problem for me! 🎉I have solved the problem using the below steps.
In my case, the emulator was on airplane mode. Make sure your emulator or mobile phone can communicate with the Metro server.
Hi everybody~
### Here is my solution
None of the above solutions can solve my problem but only follow the below steps working for me. Add in
network-security-config.xml
fileThen update
AndroidManifest.xml
file withSame here using
npx react-native run-android --variant=release
. I’ve used./gradlew clean
intoandroid
folder but the issue persists. No sign of this problem in debug mode. I’m using RN0.69.3
.If you are encountering this issue on Android 28+ in Debug Mode, make sure you add this to your
AndroidManifest.xml
:In my case, the app was running ok in
Production Mode
, but it didn’t start inDebug Mode
. Because of some network security issues, the app was unable to connect to the Metro bundler, even when it was running.Source: https://reactnative.dev/docs/integration-with-existing-apps#cleartext-traffic-api-level-28
For more details & more fine grained approaches: https://github.com/facebook/react-native/issues/22375
I still have that problem. someone help please. my emulator is not in airplane mode
I am having this issue in release mode
Same thing for me. Did you ever get this working on a real device?
I’ve solved it in this way. Hope it helps.