1. 介绍
React Native充分利用了Facebook的现有轮子。可以说既拥有Native的用户体验、又保留React的开发效率。详细可看参考文献1和2.
2. 安装测试
2.1 SDK location not found 问题
注意如果出现这样问题。
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
下面是解答原文:
Go to the android/ directory of your react-native project
Create a file called local.properties with this line:
sdk.dir = /Users/USERNAME/Library/Android/sdk
Where USERNAME is your username
2.2 SDK build error
安装相应的sdk版本,在Android Studio
下安装。因为有可能出现Android SDK
版本没装的情况。
2.3 无法connect device
windows下要先把sdk\platform-tools加入到path,就是Android Studio
安装tools目录,这样才能调用里面的命令。
还有一定要注意手机设置成:开发者选项!!
小米手机会出现神奇问题:https://github.com/facebook/react-native/issues/6499
以下是小米手机的解决方法:
- enable developer mode - In your phone, go to Settings, About phone and click on MIUI version 7 times. You’ll see a pop up which says you are a developer now.
- Go back to Settings, Additional settings, Developer options and enable USB Debugging.
- Connect your phone to your PC/Mac and on the phone authorize your computer
- go back to Developer options, scroll down to find Turn on MIUI optimization and disable it. Your phone will be rebooted
- Try it now :)
2.4 安装simulator
推荐安装Genymotion
,链接。
安装完之后要安装Android
虚拟机。
2.5 解决windows无法reload
参考
[1] 我对React Native看法:http://div.io/topic/851
[2] 如何评价 React Native:https://www.zhihu.com/question/27852694
因为我们是朋友,所以你可以使用我的文字,但请注明出处:http://alwa.info