Setting ANDROID_HOME for your VSTS agent.

I was preparing a demo for a Xamarin iOS and Android app.  I decided to stand up a private agent so my queue times would be as short as possible. You can read more on why I prefer private agents in my post Private build agents are a benefit. When I queued my build, I got the following error on the Android Signing task:

##[error]The ANDROID_HOME environment variable is not set for the running user.

To confirm this error message, I opened a terminal on my Mac and typed:

export

This listed all the environment variables on my machine. ANDROID_HOME was not listed.

Because I have Visual Studio for Mac on my machine and have built Android apps, I knew I must have the Android SDK on my machine. The question was, where was it?  I opened Visual Studio and from the Visual Studio menu I selected Preferences… In the left navigation, select SDK Locations. Select Android and click the Locations tab. Copy the value in the Android SDK Location text box.

Now with this value I need to update my ~/.bash_profile so when I run my VSTS agent, my ANDROID_HOME environment variable would be set. From the terminal I typed:

sudo vi ~/.bash_profile

Add the following to the file replacing {path to SDK} with the value on your clipboard.

export ANDROID_HOME={path to SDK}

Save the file and close the terminal.

Open a new terminal and run your VSTS agent.  You can confirm your ANDROID_HOME  environment variable is correctly set by reviewing the capabilities of your agent. 

SNAGHTML3277c78f

Comments (2) -

  • Chris Miller

    4/8/2020 4:13:24 AM | Reply

    Hi Donovan,
    Is there a way to get this work with Catalina?  I've updated the .bashrc and the .zshrc to include ANDROID_HOME, but when I run the svc.sh script (uninstall, install, then start) , the ANDROID_HOME variable does not show up under the agent's capabilities.  If I stop the service and run it from a shell via run.sh, ANDROID_HOME does show up.

Add comment

Loading