Skip to content
Latchkey

Android "SDK location not found" in CI

The Android Gradle plugin cannot find the SDK. It looks at local.properties and the ANDROID_HOME/ANDROID_SDK_ROOT environment, and none point at a valid SDK.

What this error means

The build fails early with SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in local.properties.

gradle
SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local.properties file.

Common causes

ANDROID_HOME not set on the runner

CI does not export ANDROID_HOME by default, and local.properties is usually gitignored.

local.properties not present

local.properties is machine-specific and not committed, so the SDK path is missing on CI.

How to fix it

Export ANDROID_HOME

  1. Set ANDROID_HOME to the SDK directory on the runner.
  2. Make sure the SDK is actually installed at that path.
shell
export ANDROID_HOME=$HOME/Library/Android/sdk
./gradlew assembleDebug

Write local.properties in a setup step

Generate local.properties pointing at the SDK rather than committing it.

shell
echo "sdk.dir=${ANDROID_HOME}" > local.properties

How to prevent it

  • Use a runner image with the Android SDK preinstalled and ANDROID_HOME set, or set it in your job environment. Managed runner images that include the SDK avoid this entirely.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →