I'm having an issues where System.getenv() is returning null for the environment variable. My password is stored in the RELEASE_PASSWORD environment variable. When I do:
$ echo $RELEASE_PASSWORD
it prints out the correct value, so I know the variable is set.
I was originally setting the signingConfig signingConfigs.release
in the release buildType and everything was working fine, but I need different signing configs for different product flavors. If I hardcode the password, it works just like it is suppose to. Things only get wonky when I try to read the password from an environment variable.
Is it some sort of scope issue?
This is what I currently have in my build.gradle
.
android { ... signingConfigs { release { storeFile ...; keyAlias ...; storePassword System.getenv("RELEASE_PASSWORD"); keyPassword System.getenv("RELEASE_PASSWORD"); } unsigned { keyAlias ""; storePassword ""; keyPassword ""; } } buildTypes { debug { versionNameSuffix = "-DEBUG" } release { } } flavorGroups "storeFront" productFlavors { def googleVariable = signingConfigs.release def amazonVariable = signingConfigs.unsigned google { flavorGroup "storeFront" signingConfig googleVariable } amazon { flavorGroup "storeFront" signingConfig amazonVariable } } }
If the varname is not found, getenv() returns a NULL pointer. The returned value is NULL if the given variable is not currently defined.
Return Value This method returns the string value of the variable, or null if the variable is not defined in the system environment.
You can run Android Studio from the command-line to get the environment variables passed into the IDE. In Mac OS you can run it from a terminal by running /Applications/Android\ Studio.app/Contents/MacOS/studio
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With