React Native In Android

https://facebook.github.io/react-native/docs/getting-started.html#content

Requirements

  1. OS X - Only OS X is currently supported
  2. Homebrew is the recommended way to install nvm, watchman, and flow.
  3. Install Node.js 4.0 or newer.
    • Install nvm with Homebrew or its setup instructions here. Then run nvm install node && nvm alias default node, which installs the latest version of Node.js and sets up your terminal so you can run it by typing node. With nvm you can install multiple versions of Node.js and easily switch between them.
    • New to npm?
  4. brew install watchman. We recommend installing watchman, otherwise you might hit a node file watching bug.
  5. brew install flow. If you want to use flow.

We recommend periodically running brew update && brew upgrade to keep your programs up-to-date.

Quick Start

按照Tutorial的教程,安装上面Requirements的东东

$ react-native --helpCommand `--help` unrecognizedUsage: react-native Commands:  start: starts the webserver  install: installs npm react components  bundle: builds the javascript bundle for offline use  new-library: generates a native library bridge  android: generates an Android project for your app  
  1. $ react-native run-android //运行并安装Android App
  2. $ react-native start //运行mock server
注意1. 目前react-native 的8081是hardcode的2. 运行时一定要注意server的端口有没有冲突,因为8081是hardcode,因此有些虚拟机等会占用端口,我当时就一直与Parallels的端口冲突,搞了半天都访问不到

Summary

react-native 的很多特性和API在Android上还没有实现,比如Android没有修改url的接口,也不能bundle,因此目前只能玩玩demo,等1.0版本吧

Sep 24 2015 续...

今天看到了weibo转发的一篇关于react-native android的文章,于是赶紧拿来玩玩,地址
https://github.com/race604/ZhiHuDaily-React-Native

是用react-native实现的一个知乎日报, 玩了玩发现,如果是一个native developer想要用react-native来做些事情还是挺难的,总结了一下大概有以下几点

  1. 天然的排斥
    作为一个native developer想要接受其他语言或者平台来写app确实有些难,期初我也是排斥的,感觉这玩意儿特么能写出什么来,怎么实现复杂的交互逻辑,但是最终我还是抑制着这个想法写了一些sample,不过心里的草泥马还是跃跃欲试,每当有任何block的时候就会跳出来两只
  2. 语言不通
    Native developer的语言面比较窄,大多android developer仅限于java,而iOS developer也就OC而已,swift在我调查了几个iOS dev后发现用的人确实也不多,因此,上手像react-native这种玩意儿会在语言上浪费一些时间,就连我想把请求的数据切到local都花了点儿时间,这种挫败感会感觉到自己的智商被强烈的.... 两只
  3. Debug困难
    每次error都是在界面弹出一个stack,没有AS上那种丰富的信息可以让你参考,这种同样会增多学习过程中的挫败感
  4. 相关的资源太少
    新出的玩意儿,相关的资源实在是少,很难在遇到问题时能够无脑的找到解决方案

综上所述,感觉react-native真正适用的人群应该是做过前段的开发者,这样能够帮助他们快速的实现一个APP的原型,甚至是真正的产品,上述的障碍在一个web developer看来可能不是什么大问题。

更多相关文章

  1. ADROID2.2系统多国语言定制
  2. 解决 Android(安卓)SDK下载和更新失败“Connection to https://d
  3. android studio基础知识2 -- 设置代理,轻松下载sdk
  4. Android(安卓)反汇编Smali语言中插入log打印
  5. Android(安卓)studio中为app添加多语言支持
  6. Android(安卓)Please ensure that adb is correctly located at
  7. 使用adb出现假emulator的解决方法
  8. Android4.4.2配置修改记录
  9. android中多语言的设置

随机推荐

  1. Android 打开软键盘
  2. Android SeekBar(拖动条)
  3. Android ApiDemo 笔记(一)Content与Graphic
  4. Android库. 1 UDP客户端
  5. android下拉菜单——选择星座
  6. 很好的Android论坛
  7. android 开源项目(城市定位)
  8. Android中获取当前进程名称
  9. 关于Android中xstreamjar冲突
  10. Android 自定义时间选择器