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
- Set ANDROID_HOME to the SDK directory on the runner.
- Make sure the SDK is actually installed at that path.
shell
export ANDROID_HOME=$HOME/Library/Android/sdk
./gradlew assembleDebugWrite local.properties in a setup step
Generate local.properties pointing at the SDK rather than committing it.
shell
echo "sdk.dir=${ANDROID_HOME}" > local.propertiesHow 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
Android "Failed to install SDK packages (licenses not accepted)" in CIFix the Android "Failed to install the following SDK packages as some licences have not been accepted" error…
Android Gradle "Could not determine java version" / wrong JDK in CIFix Android Gradle "Could not determine java version" and JDK mismatches in CI by installing and selecting a…
Android "AAPT2 error: check logs for details" in CIFix the Android "AAPT2 error: check logs for details" message in CI by running with --stacktrace to surface t…