React Native Genymotion配置

按照官网介绍:


React Native Genymotion配置_第1张图片

下载地址:https://www.genymotion.com/download

mac直接下载,下载完毕,安装时可以选择个人版本(免费的)


React Native Genymotion配置_第2张图片

模拟器创建完毕,运行native项目报错:

unable to load script from assets 'index.android.bundle'


直接在电脑浏览器上打开:http://localhost:8081/index.android.bundle?platform=android 就可以查看到当前最终编译成的文件:

可以看到:Cannot find entry file index.android.js in any of the roots



解决方案:

1、

I've encountered the same issue while following the React Native tutorial (developing on Linux and targeting Android).

This issue helped me resolve the problem in following steps.

(1)(in project directory) mkdir android/app/src/main/assets

(2)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

(3)react-native run-android

You can automate the above steps by placing them in scripts part of package.json like this:

"android-linux": "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"

Then you can just execute npm run android-linux from your command line every time.


参考地址:Unable to load script from assets index.android.bundle on windows


2、运行 react-native run-android,在模拟器中:


React Native Genymotion配置_第3张图片



React Native Genymotion配置_第4张图片
React Native Genymotion配置_第5张图片


设置完毕

你可能感兴趣的:(React Native Genymotion配置)