unable to load script from assets react-native

在运行react-native 项目时
报错:

unable to load script from assets ‘index.android bundle‘ ,make sure your bundle is packaged correctly or youu‘re runing a packager server

我的解决方法:

  1. (in project directory) mkdir android/app/src/main/assets
  2. yarn remove babel-preset-react-native
  3. yarn add babel-preset-react-native@2.1.0
  4. 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
  5. react-native run-android

推荐阅读更多精彩内容