Using RN 64.0 and fastlane, I have the following build command
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
In app/build.gradle
I have added the env. config files like so:
project.ext.envConfigFiles = [
stagingdebug: ".env.staging",
stagingrelease: ".env.staging",
productiondebug: ".env.production",
productionrelease: ".env.production",
]
For some reason when I run the build command, in other words fastlane android build_production
, and install the apk
on a device, the config file is an empty object when being consumed from import env from 'react-native-config';
When I run npx react-native run-android --variant stagingrelease"
, the app works as expected and gets the config.