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

后端 未结 30 1884
你的背包
你的背包 2020-11-28 19:16

react-native run-android command terminates by leaving a message in android simulator. The message is as follows:

Unable to load script.Make

相关标签:
30条回答
  • 2020-11-28 19:47

    Try These steps if you have tried everything mentioned in above solutions:

    1. Create File in android/app/src/main/assets
    2. 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

    1. Now run your command to build for e.g. react-native run-android
    0 讨论(0)
  • 2020-11-28 19:48

    If you are on linux open the terminal from the App root directory and run

    npm start
    

    then open another terminal window and run:

    react-native run-android
    
    0 讨论(0)
  • 2020-11-28 19:48

    I just want to add a non-obvious possibility not covered here. I am using @react-native-community/netinfo for detecting network changes, primarily network state. To test network-off state, the WIFI switch (on the emulator) needs to be switched off. This also effectively cuts off the bridge between the emulator and the debug environment. I had not re-enabled WIFI after my tests since i was away from the computer and promptly forgot about it when i got back.

    There is a possibility that this could be the case for somebody else as well and worth checking before taking any other drastic steps.

    0 讨论(0)
  • 2020-11-28 19:49

    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.

    0 讨论(0)
  • 2020-11-28 19:50

    If you are running on Linux OS,there might be case where your npm remote server is not running. Open another terminal (with project directory) and run this command sudo npm start or sudo react-native start before doing sudo react-native run-android

    0 讨论(0)
  • 2020-11-28 19:52

    Apparently, none of the answers fixed the issue for me. I was able to run the react-native app on emulator but the same code (even when the Server was running), gave me this error when running the app on the device.

    I was able to resolve it by executing the following command in the terminal:

    adb reverse tcp:8081 tcp:8081

    0 讨论(0)
提交回复
热议问题