- 环境
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配置
未配置