Maurits van Beusekom Maurits van Beusekom - 4 months ago 8x
Android Question

ANDROID_HOME not set (VSTS agent running as service on OS X)

I have configured the VSTS agent on my MacBook Pro and it works perfectly when I manually run it (using


However when I configure the VSTS agent to run as a service (using
./ install
./ start
) and queue a new build in VSTS I receive an error (on the signing step) "ANDROID_HOME not set".

I have the following configured in my .bash_profile:

export ANDROID_HOME=/Users/$(whoami)/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

The path is correct and also running
returns the expected value (in this case

Does anybody know what could be wrong?


In your agent folder, there is a file named Add your export in there. You'll see a commented-out line prompting you where to put your env setup:

# insert anything to setup env when running as a service
export ANDROID_HOME=/Users/$(whoami)/Library/Android/sdk

Make sure to restart the service.

The reason .bash_profile doesn't work for you is because the service doesn't have access to that when it runs.

I had the same problem and found the solution here:

For those developing with Xamarin, you'll typically need this instead:

# insert anything to setup env when running as a service
export ANDROID_HOME=/Users/$(whoami)/Library/Developer/Xamarin/android-sdk-macosx