Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

What is Metro server in react native?

Metro is a development platform for React Native. This project acts as a JavaScript bundler; it manages assets, caches builds and performs hot module reloading. Metro focuses on improving the developer experience for the React Native community.


You haven't started the bundler yet. Run npm start or react-native start in the root directory of your project before react-native run-android.


These steps really help me:

Step 1: Create a directory in android/app/src/main/assets

Linux command: mkdir android/app/src/main/assets

Step 2: Rename index.android.js (in root directory) to index.js (Maybe there is an index.js file in which case you do not need to rename it) then run 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

Step 3: Build your APK: react-native run-android

Please use index.js in latest version.

Enjoy :)


For me this error was caused by an upgrade of react-native

Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

If you check out the upgrade diff you need to create a debug manifest android/app/src/debug/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>

See for more info: https://stackoverflow.com/a/50834600/1713216

https://react-native-community.github.io/upgrade-helper/


A similar issue happened with me.
Apparently Mcafee blocks 8081 port. Took me hours to figure this out.

Try running:

react-native run-android --port=1234

When app shows up with an error on emulator, get into dev settings (Ctrl+M).

Change the "Debug server host and port for device" to "localhost:1234".

Close the app and start it from the app drawer.