0

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.

1 Answer 1

1

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:

gradle(task: 'assemble', flavor: "staging", build_type: 'Release', project_dir: 'android/', system_properties: {"ENVFILE": ".env.staging" })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.