(React-Native 学习之四) RN 官方Demo 搭建 RNTester 运行
来源:互联网 发布:网络教育统考报考失败 编辑:程序博客网 时间:2024/05/17 06:46
一,前言:
学习react-native相信对于我们最好的教程就是官方教程。因此学习和查看官方demo。是我们学习进步的阶梯。本文是博主学习react-native中遇到的一些基本问题,分享出来供大家学习和参考:
转载请注明出处:http://blog.csdn.net/u013233097/article/details/78362760 如果对你有用,欢迎fork或者star。或者点赞关注以及评论。
二,准备工作:
官方UIExplorer demo 是需要我们配置环境才能运行的。
准备工作:npm , node, git 具体安装法方式看我前几篇文章。
三,Action 开始行动:
1,打开 gitbash , 执行命令:
git clone https://github.com/facebook/react-native.git
clone 成功后 react-native 内容:
2, 打开自带的 示例包 :
注意: rn 各个版本示例包名不一样,有的是在 examples文件夹下,有的是在 RnTester下:
找到 示例包 :
3, 打开README.md 说明文件:
查看提示:
// 以运行 Android app 为例:## Running this appBefore running the app, make sure you ran: git clone https://github.com/facebook/react-native.git cd react-native npm install
根据提示执行命令:
4, 继续查看文档:
### Running on AndroidYou'll need to have all the [prerequisites](https://github.com/facebook/react-native/tree/master/ReactAndroid#prerequisites) (SDK, NDK) for Building React Native installed.Start an Android emulator ([Genymotion](https://www.genymotion.com) is recommended). cd react-native ./gradlew :RNTester:android:app:installDebug ./scripts/packager.sh_Note: Building for the first time can take a while._Open the RNTester app in your emulator.See [Running on Device](https://facebook.github.io/react-native/docs/running-on-device.html) in case you want to use a physical device.
继续根据文档提示 输入命令: ./gradlew :RNTester:android:app:installDebug
发现报错, 下载boost 失败:
:ReactAndroid:downloadBoostInvalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Sat, 28 Nov 2037 09:05:12 -0000; secure; HttpOnly". Invalid 'expires' attribute: Sat, 28 Nov 2037 09:05:12 -0000:ReactAndroid:downloadBoost FAILED
从网上找到对应版本(一般错误信息会提示),粘贴复制进:ReactAndroid- build-downloads 文件夹下:
5,继续执行命令:
./gradlew :RNTester:android:app:installDebug
安装成功:
可以看到 我们模拟器上已经被安装了RnTester:
6,启动服务命令:
./scripts/packager.sh
开启成功后:打开 我们的App RNTester 运行成功:
官方Demo. 仅供学习。
需要资源者: 请异步github:https://github.com/zqHero/RNTesterDemo
如果对你有用别忘了 fork 和 star 哦。
错误信息提示:
1.Error:Execution failed for task ‘:ReactAndroid:downloadBoost’.
java.io.FileNotFoundException: http://nchc.dl.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.zip
手动下载boost_1_57_0.zip 复制到/node_modules/react-native/ReactAndroid/build/downloads目录下,下载不了请使用vpn。
2.Error:Execution failed for task ‘:ReactAndroid:downloadJSCHeaders’.
java.net.UnknownHostException: svn.webkit.org
到https://svn.webkit.org/repository/webkit/!svn/bc/174650/trunk/Source/JavaScriptCore/API/ 下载[‘JavaScript.h’, ‘JSBase.h’, ‘JSContextRef.h’, ‘JSObjectRef.h’, ‘JSRetainPtr.h’, ‘JSStringRef.h’, ‘JSValueRef.h’, ‘WebKitAvailability.h’]
复制到/node_modules/react-native/ReactAndroid/build/downloads/jsc目录下。
3.Error:Execution failed for task ‘:ReactAndroid:buildReactNdkLib’.
Process ‘command ‘/Users/shixiang/Library/Android/android-ndk-r11b/ndk-build” finished with non-zero exit value 2
这个是我遇到的ndk版本问题,使用android-ndk-r10e后正常。
- (React-Native 学习之四) RN 官方Demo 搭建 RNTester 运行
- 《React-Native系列》 RN学习之NodeJS
- 《React-Native系列》 RN学习之NodeJS
- Windows下RN环境搭建及官方Demo运行
- React Native官方DEMO
- RN学习系列---Windows下安装搭建React-Native环境
- 《React-Native系列》14、 RN学习之NodeJS
- React Native配置运行官方Example Demo 等等
- RN(react native)入坑指南-03,运行官方示例UIExplorer
- React Native for Android 学习笔记(一) 操蛋的环境搭建与demo运行
- 《React-Native系列》28、 RN之AsyncStorage
- 《React-Native系列》28、 RN之AsyncStorage
- RN-第三方之-react-native-fs
- <React Native> 学习日记(1) 成功运行、编译RN-android的爬坑记录
- react native 学习实践----运行facebook官方提供的例子
- React Native学习四
- React Native学习笔记之--向原生应用中集成RN页面
- React-Native学习之制作RN版的微博app(一)
- 中国移动苏州研发中心前端笔试(2)
- Java
- Android事件分发机制
- 三言两语之js事件、事件流以及target、currentTarget、this那些事
- 39、我的C#学习笔记5
- (React-Native 学习之四) RN 官方Demo 搭建 RNTester 运行
- 为什么Intent或Bundle中携带的对象需要支持序列化?
- npm全局安装模块时报‘maximum call stack size’
- c语言中rand()函数的用法笔记
- 表达式求值——栈实现
- 【Python】Python线程指南
- 不得不说,minigui真的很坑
- Vuex学习小记(action)
- servlet入门-1(写的超级清楚)