Android “SDK location not found”: set ANDROID_HOME or sdk.dir
Install the SDK via SDK Manager, then point the build at it with ANDROID_HOME or local.properties.
Install an SDK platform in Tools > SDK Manager, then set ANDROID_HOME to the SDK directory (for example ~/Library/Android/sdk on macOS) or add sdk.dir=/path/to/sdk to local.properties. Use ANDROID_HOME only; ANDROID_SDK_ROOT is deprecated.
Try these fixes in order
Verify the SDK is installed
Confirm the SDK actually exists. In Android Studio open Tools > SDK Manager and check that a platform and build-tools are installed.
Set ANDROID_HOME
Point builds at the SDK with the environment variable. Add the export to your shell profile so it persists.
export ANDROID_HOME=~/Library/Android/sdkOr set sdk.dir in local.properties
Alternatively, write the SDK path into local.properties at the project root. Keep this file out of version control.
sdk.dir=/Users/you/Library/Android/sdkClear the deprecated variable
Remove the deprecated ANDROID_SDK_ROOT if it disagrees with ANDROID_HOME, then sync the project again.
./gradlew --versionInterpret what you see
Fresh Android Studio install
What it suggests: The SDK platform and build tools were never installed; there is nothing for ANDROID_HOME to point at.
Next check: Open Tools > SDK Manager and install a platform plus build-tools.
Command-line builds fail but the IDE works
What it suggests: The SDK exists but the build cannot find it, common on CI machines and new shells.
Next check: Export ANDROID_HOME to the SDK directory in your shell profile.
Both ANDROID_HOME and ANDROID_SDK_ROOT are set
What it suggests: ANDROID_SDK_ROOT is deprecated; when both variables exist, the plugin checks they agree and can fail on mismatch.
Next check: Use ANDROID_HOME only and remove the old variable.
Why this happens
- The Android SDK is not installed, or nothing points the build at it.
- ANDROID_HOME is unset and local.properties has no sdk.dir entry.
Still not working?
Do not copy another machine's local.properties into version control; sdk.dir is machine-specific and belongs in .gitignore. Set ANDROID_HOME per machine instead.
Official sources
These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.