react-native-config 使用
- 环境
react-native 0.7.0 - 安装
npm i -S react-native-config - 设置.env文件
// .env.staging
API_URL = https://dev.xxxx.com
- 配置package.json
"scripts": {"android:staging": "ENVFILE=.env.staging react-native run-android",},
- 安卓配置
android/app/build.gradle 文件最末尾
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
- 打包时指定环境
$ cd android && ENVFILE=.env.staging ./gradlew assembleRelease - 解决
Failed to transform react-native-0.71.0-rc.0-release.aar
android/app/build.gradle
buildscript {// ...
}allprojects {repositories {exclusiveContent {filter {includeGroup "com.facebook.react"}forRepository {maven {url "$rootDir/../node_modules/react-native/android"}}}// ...}
}
参考来源 https://github.com/facebook/react-native/issues/35204
- iOS配置
未配置
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
