Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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$
like image 289
Ryan Langton Avatar asked Apr 01 '17 13:04

Ryan Langton


2 Answers

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.

like image 143
rahulrvp Avatar answered Oct 13 '22 01:10

rahulrvp


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.

like image 24
Ryan Langton Avatar answered Oct 13 '22 02:10

Ryan Langton