react-nativebuild.gradlereact-native-config

react-native-config unable to use env variables in build.gradle


I have react-native-config set up and use it in javascript no problem but am unable to use it like this in build.gradle.

release {
     if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
         storeFile file(project.env.get("MYAPP_RELEASE_STORE_FILE"))
         storePassword project.env.get("MYAPP_RELEASE_STORE_PASSWORD")
         keyAlias project.env.get("MYAPP_RELEASE_KEY_ALIAS")
         keyPassword project.env.get("MYAPP_RELEASE_KEY_PASSWORD")
     }
}

versions

react-native-cli: 2.0.1
react-native: 0.49.5
react: 16.0.0
react-native-config: 0.11.1

Output

$ ./gradlew assembleRelease`
... shortened output
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file not set for signing config release

Solution

  • In gradle build you use project.env.get("VAR NAME")