1.进入到项目根目录,在main下建立一个assets文件夹,mkdir android/app/src/main/assets
2.运行命令:
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.最后在执行命令: react-native run-android
注意:Using npm version 4.3.0 react-native-cli version 2.01 react-native version 0.49.5.In project directory.
The file name has changed fromindex.android.jstoindex.js.词句意思是说,react-native-cli version 2.01以后index.android.js已经被替换为index.js
因此,执行应变成如下命令:
mkdir android/app/src/main/assets
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
react-native run-android