Directory:

  1. Release notes
  2. Content of the error
  3. The solution

I. Version description

Mac Android Studio: 3.6.2 "React ": "16.8.3"," React -native": "0.59.9"Copy the code

Second, inAndroidAndroid environment,Android StudioThe following error occurred while running the startup project in:

 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. ......
Copy the code
  • The diagram below:

Solutions for referencehere

3.1. Check whether the file existsindex.android.bundle, there should be no such file, so follow these steps to generate

  1. directory${project name}/android/app/ SRC /main/Create folderassets
  2. Check if there are any in the projectindex.android.jsFile, if [have] execute no3Step, if no, execute no4Step command (modified no3Step commandindex.android.jsindex.js
  3. Run the following command in the project (correspondingindex.android.jsFile) :
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res 
Copy the code
  1. Run the following command in the project (correspondingindex.jsFile) :
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 
Copy the code
  1. After execution, the picture is as follows:

3.2. Re-run the project and you can successfully ✌️

react-native run-android
Copy the code
Write to oneself essay, have a question welcome to point outCopy the code