Rajkiran Rajkiran - 1 month ago 8
Android Question

Android: set sdk.dir in local.properties to ANDROID_HOME environment variable

So the

local.properties
file holds the reference to the Android SDK directory in
sdk.dir
variable. For me it is
sdk.dir=/Users/rajkiran/Library/Android/sdk
. On my CI machine, the
sdk.dir
refers to the SDK directory which points to an invalid location since the username is different.

Is there any way so that I can set SDK directory as my
ANDROID_HOME
?

Perhaps something like this:
sdk.dir=$ANDROID_HOME
, so that on my CI machine, it will set the SDK directory from the environment variable?

Answer

local.properties should not be part of the versioned code. It's used as your local project configuration and Android Studio will create it based on on ANDROID_HOME if it doesn't exist yet.

If local.properties is not available, Gradle will use ANDROID_HOME automatically.

If local.properties is available, Gradle will use this file having a wrong sdk.dir set and fail.