gradle get System environment variables

900 views Asked by At

On mac if i use this under gradle:

androidSdk ="$System.env.HOME"

it delivered an output: /Users/MyName/

and:

androidSdk ="$System.env.ANDROID_HOME"

it delivered 'null'. Altough i've set the ANDROID_HOME Variable and if i checked unter console

echo $ANDROID_HOME 

it delivered the right path.

Have anyone ever set ANDROID_HOME or something like this on gradle


ADDED:

My problems is, why $System.env.ANDROID_HOME = null, when on terminal "echo $ANDROID_HOME" give the right path??

2

There are 2 answers

0
josedlujan On

Use:

set ANDROID_HOME=/my_current_way_to/sdk

You need to use the console for this.

0
TDU On

In terminal use:

set ANDROID_HOME=/my_current_way_to_sdk ; export ANDROID_HOME

THEN, you need to run Eclipse, Android Studio, INSIDE that same terminal. Do not exit, do not open another terminal, etc. Unless you change your .profile to ALWAYS do the above line.

Or - create a shell script to do the above set/export, then immediately run whatever you are trying to run.