2026-10-23 · Q&A guide

Fix Android SDK Not Found Error in Gradle Projects

Resolve the SDK location error by correctly configuring sdk.dir or ANDROID_HOME for Gradle builds.

What Causes the SDK Not Found Error

Gradle looks for the Android SDK in two places: the local.properties file that lives in the project root, and the ANDROID_HOME environment variable. If neither contains a valid path, the build aborts with "SDK location not found". This often happens when a project is opened in a new IDE session or when the SDK has been moved after the project was created.

Verify the SDK Path on macOS

Open a terminal and run:

``` ls -l /Users/$(whoami)/Library/Android/sdk ```

Make sure the directory exists and contains subfolders like build-tools, platform-tools, and platforms. If the path is wrong or the folder is missing, reinstall the SDK or update the path to the correct location.

Create or Update local.properties

In the root of the project that Gradle is building, create or edit the file named local.properties. It should contain a single line:

``` sdk.dir=/Users/$(whoami)/Library/Android/sdk ```

Do **not** add any spaces after the slash. The file is ignored by Git, so it can be committed locally without affecting other developers.

Set ANDROID_HOME in Your Shell

If you prefer an environment variable, add the following to your shell profile (e.g., ~/.zshrc or ~/.bash_profile):

# ~/.zshrc or ~/.bash_profile
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools"

Refresh Gradle and Restart Android Studio

After modifying local.properties or your shell profile, restart Android Studio so it reloads the environment. Then run:

``` ./gradlew clean build ```

or use the Gradle tool window to "Refresh all Gradle projects." The error should disappear once Gradle can locate the SDK.

Takeaway: A correctly set sdk.dir in local.properties or a valid ANDROID_HOME resolves Gradle’s SDK location error.

People also ask

Can I share local.properties with other developers?

No, local.properties is meant for local machine configuration and is usually excluded from version control.

What if my SDK is installed in a non‑standard location?

Point sdk.dir or ANDROID_HOME to that directory. Gradle will use it regardless of the default installation path.

Why does the error appear only after a fresh clone?

The cloned repository lacks local.properties, so Gradle falls back to ANDROID_HOME, which may not be set in the new environment.

Inspired by a public discussion on Stack Overflow. This article is an original explanation for learners.

← All posts