搭建react-native 环境

最近有个app项目老板让用react-native做,搭建环境以防后期再用。

打开官网http://reactnative.cn/docs/0.45/getting-started.html;照着文档开始搭建

1.安装python2 下载正常安装

2.安装node下载安装

3.安装Yarn cli npm install -g yarn react-native-cli

4.java jdk 官网要求安装1.8以上版本

5.安装 Android Studio2.0

6.配置sdk

7.安装Genymotion 注:注册和登陆不要开跨域插件

下载安装完毕 安装模拟器5.1.0以上版本 之后将其adb设置为自己的安卓sdk 不然打开之后自己的adb 会报错,5037端口被占用。

8.新建项目 react-native init xx 注:(xx--项目名)

9.跑新项目 react-native run-android

最近发现在跑模拟器的时候可能会报

unable to load script from assets index.android.bundle"这个错误

解决方案是在android/app/src/main/新建一个assets文件夹之后运行

https://stackoverflow.com/questions/44446523/unable-to-load-script-from-assets-index-android-bundle-on-windows可以查看这里

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

这个命令之后应该可以运行

这个问题在真机上还没有发现 

10.在模拟器上可能会报 Could not connect to development server

最近新版本没报这个错。这个还是node服务器的错误,因为node是运行在8081端口

以上内容借鉴或者引用的内容来自

http://blog.csdn.net/u014175342/article/details/73823904;

http://blog.csdn.net/fengyuzhengfan/article/details/53366252;

http://blog.csdn.net/qq_25827845/article/details/52974991;

以上博客