React-Native 在window下开发andriod
2015-12-21 13:54
651 查看
之前搞安卓开发,电脑上了装了JDK,和AS。环境变量都配置一下。
然后去下载Node.js。命令行安装
final def TARGET_BUNDLE_FILE = 'index.android.bundle'
final def DOWNLOAD_URL = 'http://localhost:8081/index.android.bundle?platform=android&dev=false&minify=true'
task downloadJSBundle << {
def dir = new File(TARGET_BUNDLE_DIR)
if (!dir.exists()) {
dir.mkdirs()
}
def f = new File(TARGET_BUNDLE_DIR + TARGET_BUNDLE_FILE)
if (f.exists()) {
f.delete()
}
try {
new URL(DOWNLOAD_URL).withInputStream{ i -> f.withOutputStream{ it << i }}
} catch (Exception e) {
e.printStackTrace()
}
}
然后重新运行就可以了。
然后去下载Node.js。命令行安装
npm install -g react-native-cli
然后
react-native init XXXXXX是你项目的名字
Node.js现在都自己配置环境变量。
然后等一会,初始化挺慢的
然后 启动react-native
react-native start
这个也不快,等启动了,切换到项目目录 cd XXX
启动模拟器 ,adb devices 看一下有无设备 也可以真机
react-native run-android 就可以了
真机如果不行就在
项目下的app文件夹下对build.gardle 文件修改在最末尾加上final def TARGET_BUNDLE_DIR = 'app/src/main/assets/'
final def TARGET_BUNDLE_FILE = 'index.android.bundle'
final def DOWNLOAD_URL = 'http://localhost:8081/index.android.bundle?platform=android&dev=false&minify=true'
task downloadJSBundle << {
def dir = new File(TARGET_BUNDLE_DIR)
if (!dir.exists()) {
dir.mkdirs()
}
def f = new File(TARGET_BUNDLE_DIR + TARGET_BUNDLE_FILE)
if (f.exists()) {
f.delete()
}
try {
new URL(DOWNLOAD_URL).withInputStream{ i -> f.withOutputStream{ it << i }}
} catch (Exception e) {
e.printStackTrace()
}
}
然后重新运行就可以了。
相关文章推荐
- android studio 配置react环境
- ReactJs的一些记录
- Windows环境搭建React Native Android的开发环境
- React-Flux 介绍及实例演示
- React-用ImmutableJS提高性能
- React Jest测试
- React如何性能调优
- React 性能调优原理
- React使用rAF动画介绍
- React用JS 模拟动画介绍
- 如何在React中使用CSS3动画
- java识别验证码-用tess4j实现超简单调用tessreact-orc来破解验证码
- React表单组件自定义-可控及不可控组件
- 大神眼中的React Native--备用
- React事件处理函数的bind复用和name复用
- React表单元素的使用
- ReactJS学习笔记(三)
- 用ReactJS和Python的Flask框架编写留言板的代码示例
- 用ReactJS和Python的Flask框架编写留言板的代码示例
- React可控组件与不可控组件