rect-native开发环境搭建 http://reactnative.cn/docs/0.45/getting-started.html#content
按照上面的文档react-native run-ios 运行成功,前提是你得具备原生ios环境和react-native环境
react-native run-android 无法启动遇到好多坑,我android studio环境也是配置好的
第一次运行 react-native run-android的时候 终端显示 一直Download distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
下这个包电脑必须翻墙,然后下了10多分钟才下完,下完后会有一堆自动编译命令
编译完成后 我继续运行 react-native run-android,提示我Android环境变量没配置好
一次运行下面三个命令
cd ~
vi .bash_profile
配置SDK路径和Android环境变量
export ANDROID_HOME=/Users/super/Library/Android/sdk
export PATH=${PATH}:/Users/super/Library/Android/sdk/platform-tools
export PATH=${PATH}:/Users/super/Library/Android/sdk/tools
配置完成后
source .bash_profile
再使用adb命令 成功的话说明环境变量配置好,我又接着到项目根目录下运行
react-native run-android
提示:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable
还是找不到 ANDROID_HOME
我也无解了,在google上搜到了解决办法,在当前项目目录下的android根目录下创建一个local.properties文件,直接把android目录写死
sdk.dir=/Users/super/Library/Android/sdk
react-native run-android
又有问题了,下面的意思是需要23这个版本的SDK,我又打开Android Studio 把 Android SDK Platform 23 下载下来然后 勾选上
Android SDK Platform 23 就是android 6.0
You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 23].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
感觉差不多要大功告成了
react-native run-android
提示找不到模拟器 或 手机
我就用Android Studio 启动了模拟器
react-native run-android
终于完美运行