# Environment variable null in Android Gradle build

**URL:** <https://discuss.circleci.com/t/environment-variable-null-in-android-gradle-build/22531>\
**Category:** Build Environment\
**Tags:** android\
**Created:** [May 24, 2018, 6:27am UTC](https://discuss.circleci.com/t/environment-variable-null-in-android-gradle-build/22531 "2018-05-24T06:27:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcintelematics](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@rcintelematics](https://discuss.circleci.com/u/rcintelematics)\
**Post date:** [May 24, 2018, 6:27am UTC](https://discuss.circleci.com/t/environment-variable-null-in-android-gradle-build/22531/1 "2018-05-24T06:27:08Z")

</div>

Hello,  
Any environment variable I set via the UI is always null when fetched in my Android gradle build. I have a function which tries to return values from a properties file when running local builds, but on the CI environment in Circle it fetches from the environment variable since this file isn’t checked into source control.

e.g.  
`getPropOrEnvValue = { param1, param2 -> def val = keystoreProperties[param1] != null ? keystoreProperties[param1] : "$System.env.param2" println('ENV ' + param2 + " = " + val) return val }`

```
keyAlias getPropOrEnvValue('keyAlias', 'KEY_ALIAS')

```

I’ve seen a [few threads](https://stackoverflow.com/questions/35440907/can-circle-ci-reference-gradle-properties-credentials) from a year or two ago indicating Gradle can’t read env variables within Circle, and that you need to add them to gradle.properties via a script. This seems a bit of an inconvenience, is this still the case or am I just doing things wrong?

FYI,  
Using Circle 2.0, with a small modification to the circleci/android:api-26-alpha image.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [August 22, 2018, 6:27am UTC](https://discuss.circleci.com/t/environment-variable-null-in-android-gradle-build/22531/2 "2018-08-22T06:27:11Z")

</div>

Closed on August 22, 2018, 6:27am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
