React-native
// 全局安装
npm install react-native-cli -g
// 初始化一个项目
react-native init HelloWorld
// 运行服务,用于生成js bundle
react-native start
ract-native run-android #在手机上或者模拟器上运行android应用
F:\react-native\HelloAndroid>react-native start
┌────────────────────────────────────
──────────────────────────────────────
│ Running packager on port 8081.
│
│
│
│ Keep this packager running while developing on any JS projects. Feel
│
│ free to close this tab and run your own packager instance if you
│
│ prefer.
│
│
│
│ https://github.com/facebook/react-native
│
│
│
└────────────────────────────────────
──────────────────────────────────────
Looking for JS files in
F:\react-native\HelloAndroid
[14:52:11] <START> Building Dependency Graph
[14:52:11] <START> Crawling File System
[Hot Module Replacement] Server listening on /hot
React packager ready.
[14:53:11] <END> Crawling File System (59505ms)
[14:53:11] <START> Building in-memory fs for JavaScript
[14:53:11] <END> Building in-memory fs for JavaScript (531ms)
[14:53:11] <START> Building in-memory fs for Assets
[14:53:12] <END> Building in-memory fs for Assets (335ms)
[14:53:12] <START> Building Haste Map
[14:53:12] <START> Building (deprecated) Asset Map
[14:53:12] <END> Building (deprecated) Asset Map (77ms)
[14:53:13] <END> Building Haste Map (1302ms)
[14:53:13] <END> Building Dependency Graph (61687ms)
http://localhost:8081/index.android.bundle?platform=android
react-native run-android
REF
5/6/2016 2:52:32 PM
需要配置android sdk...
运行react-native run-android会安装gradle有点慢
# 注意
Android 真机调试
示例 App 直接部署到真机,红色界面报错,无法连接到 Debug Server。
如果是 5.0 或者以上机型,可通过 adb 反向代理端口,将 Mac 端口反向代理到测试机上。
adb reverse tcp:8081 tcp:8081
如果 5.0 以下机器,应用安装到测试机上之后,摇动设备,在弹出菜单中选择 Dev Setting > Debug Server host for device,然后填入 Mac 的 IP 地址(ifconfig 命令可查看本机 IP)
关于修改 DevHelper 来进行和 iOS 一样的开发调试,后续关于热部署时,我会介绍到。
=======
模拟器摇动不会,真机可以,
点击Dev Settings
点击最下面的 填写你电脑的ip 这里我用的花生壳映射
ref
2016-5-18
- 安装 android-studio 会安装studio和sdk
- 模拟器genymotion 因为google官方的模拟器太卡 下载需要到官网注册个帐号,启动的时候会有些错误,显卡驱动升级,ip问题