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 1886
你的背包
你的背包 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:36

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

    This is what you need to do to get rid of this problem if you do normal run commands properly

    1. npm install
    2. react-native start
    3. react-native run-android

    And modify your android manifest file like this.

    <application
        android:name=".MainApplication"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true" // add this line with TRUE Value.
    android:theme="@style/AppTheme">
    
    0 讨论(0)
  • 2020-11-28 19:36

    The solution that worked for me is the following:

    var sharedBlacklist = [
      /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
      /website\/node_modules\/.*/,
      /heapCapture\/bundle\.js/,
      /.*\/__tests__\/.*/
    ]; 
    

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

    possibility of this error is also the wrong path,check once

     export ANDROID_HOME=/Users/microrentindia/Library/Android/sdk/
     export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
    
    0 讨论(0)
  • 2020-11-28 19:39

    IMPORTANT - You might have many Virtual devices in your environment. Ensure if you are changing AVD you repeat the setting again.

    DEBUG INFORMATION-

    Incase you are experiencing above error you have to 1st verify what is running on port 8081

    Quickest way to find that is using the following command in terminal

    netstat -aon | findstr 8081
    

    if that shows you something it means the port is blocked. if possible get that port unblocked.

    Otherwise, you would need to change the port. The process to do that has already been mentioned in the comment above by Naveen Kumar

    react-native run-android --port=9001
    

    Ensure 9001 is not used either :)

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

    My solution to this is as below:

    Start Metro server

    $ react-native start
    

    Start Android

    $ react-native run-android
    

    If see errors saying "port 8081 already in use", then you can kill that process and rerun

    $ react-native start
    

    See React Native Troubleshooting Page .

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

    The error message on the emulator is kind of misleading. In my case, I used a Macbook. I needed to change the permissions on android/gradlew by running $ chmod 755 ./gradlew, and then the app could be built and deployed to the android emulator.

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