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.
injecting hte env
gradle(...)
command on fastlane did the the trick. The expected behavior was for it to resolve the right file based on the{{flavor}}{{build type}}
which doesn't seem to work with fastlane as of right now.Solution: