Ryan Langton
Ryan Langton

Reputation: 6160

NativeScript ANDROID_HOME missing

When I run tns run android or tns doctor I get an error that the ANDROID_HOME environment variable is not set. Yet it's clearly set. Mac OSX Sierra 10.12.3.

bash-3.2$ tns run android
The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
bash-3.2$ $ANDROID_HOME
bash: /Users/rlangton/Library/Android/sdk: is a directory
bash-3.2$

Upvotes: 7

Views: 4952

Answers (2)

Ryan Langton
Ryan Langton

Reputation: 6160

If you're using bash then you need to update the ~/.bash_profile file. In my case, I'm using ZSH so I needed to edit ~/.zshrc file.

nano ~/.zshrc

Add the export line below:

if [ -f /Users/{myusername}/.tnsrc ]; then
    source /Users/{myusername}/.tnsrc
    export ANDROID_HOME=/Users/{myusername}/Library/Android/sdk
fi

Ctrl + O to save, Ctrl + X to exit. Restart the terminal. Now echo $ANDROID_HOME shows the correct path every time.

Upvotes: 7

rahulrvp
rahulrvp

Reputation: 2126

Open/create .profile like this

vim ~/.profile

add the following lines to the end of the .profile file.

export ANDROID_HOME=${HOME}/Library/Android/sdk

load the profile using the command

source ~/.profile

You should have it working I guess. This is what I did to get this configured.

Upvotes: 7

Related Questions