Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ./run.sh).

However when I configure the VSTS agent to run as a service (using ./svc.sh install and ./svc.sh 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 echo $ANDROID_HOME returns the expected value (in this case /Users/mvanbeusekom/Library/Android/sdk).

Does anybody know what could be wrong?

like image 242
Maurits van Beusekom Avatar asked Jun 17 '16 21:06

Maurits van Beusekom


People also ask

What are Vsts agents?

An important part of VSTS is the Hosted Agent Pool. Agents are used to run builds, tests and releases. They do the actual work. The Hosted Pool consists of a series of Virtual Machines that are managed by Microsoft.

What is Android_home variable?

Android SDK environment variables. ANDROID_HOME. Sets the path to the SDK installation directory. Once set, the value does not typically change, and can be shared by multiple users on the same machine. ANDROID_SDK_ROOT , which also points to the SDK installation directory, is deprecated.


1 Answers

In your agent folder, there is a file named runsvc.sh. 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: https://github.com/Microsoft/vsts-tasks/issues/1726#issuecomment-219725321

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
like image 143
NovaJoe Avatar answered Sep 28 '22 01:09

NovaJoe