使用 RN 64.0 和 fastlane,我有以下构建命令
desc 'Build the Staging Android application.'
lane :build_staging do
gradle(task: 'clean', project_dir: 'android/')
gradle(task: 'assemble', flavor: "staging", build_type: 'release', project_dir: 'android/')
end
在app/build.gradle
我添加了环境。配置文件如下:
project.ext.envConfigFiles = [
stagingdebug: ".env.staging",
stagingrelease: ".env.staging",
productiondebug: ".env.production",
productionrelease: ".env.production",
]
出于某种原因,当我运行构建命令(换句话说fastlane android build_production
,并apk
在设备上安装)时,配置文件在被使用时是一个空对象import env from 'react-native-config';
当我运行时npx react-native run-android --variant stagingrelease"
,该应用程序按预期工作并获取配置。