配置与配置相关
- 首先确定环境是否搭建成功
参照文档搭建环境 https://reactnative.cn/
命令行查看 vi ~/.bash_profile 文件里面的安卓和iOS的环境变量是否正确
- 从 https://coding.net/ 上复制项目的地址clone在本地
- npm install下载项目所需要的第三方依赖库
- 连接安卓测试手机,打开开发者模式,确保设备已经连接,可以输入 adb devices 来检查设备。如果你连接了多个设备(包含模拟器在内),后续的一些操作可能会失败。拔掉不需要的设备,或者关掉模拟器,确保adb devices的输出只有一个是连接状态。
- react-native run-android 在设备上安装并启动。
- 安装成功之后在设备上报红屏错误
先摇一摇打开Dev Settings ,打开Debug server host & port for device ,输入 “ip地址: 8081” ,reload
- 去项目安卓下找到 ./gradlew , ./gradlew clean 清理一下
- 错误:Could not get unknown property 'MYAPP_RELEASE_STORE_FILE' for SigningConfig_Decorated{name=release, storeFile=null, storePassword=null, keyAlias=null, keyPassword=null, storeType=null, v1SigningEnabled=true, v2SigningEnabled=true} of type com.android.build.gradle.internal.dsl.SigningConfig.
打开 vim. ~/.gradle/gradle.properties 将这些配置添加进去:
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=szprism
MYAPP_RELEASE_KEY_PASSWORD=szprism
- 在react-native run-android 时出现如下错误:
error: bundling failed: Error: While resolving module `react-native-vector-icons/MaterialIcons`, the Haste package `react-native-vector-icons` was found. However the module `MaterialIcons` could not be found within the package. Indeed, none of these files exist:
- * `/Users/user/my-app/node_modules/react-native/local-cli/core/__fixtures__/files/MaterialIcons(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
- * `/Users/user/my-app/node_modules/react-native/local-cli/core/__fixtures__/files/MaterialIcons/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
- 原因可能是React-Native,React,React-native-vector-icons的版本问题。可以执行如下命令:
- rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json
- 在使用codepush 的时候,由于找不到绝对路径,导致不能上传的版本进行绑定版本号。需要将node_modules\react-native-update\local-cli\lib\bundle.js的439行种的metro-bundler改成metro