解决React Native unable to load script from assets index.android.bundle on windows

When React Native is running, I often encounter React Native unable to load script from assets index.android.bundle on windows. There are two solutions:

Method 1: Set IP and Port

Specific steps: shake the phone on the error page, display the menu => click Dev Settings => click Debug server host & port for device => set the IP and port (ex:192.168.0.20:8081) => click return => the page is blank, Click and shake again, select the Reload JS program and it will be displayed.

If this method still doesn't work, keep reading.

 

Method 2: The reason is that the file under assets is not found, and it needs to be created and set manually

1. First manually create an assets folder under main
2. Then cmd enters the root directory of the project and executes:

?
1
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

3. Execute react-native run-android;

 

This is the end, basically these two methods can solve React Native unable to load script from assets.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324818439&siteId=291194637