Skip to content
FR
  1. LuzineDebug
  2. Mobile (Android, iOS)
  3. SDK location not found. Define a valid SDK locat…
Mobile (Android, iOS) Beginner ≈ 5 min to fix

Fix "SDK location not found" (ANDROID_HOME / sdk.dir) on Android

Error message
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 at '/path/to/project/android/local.properties'.
  • SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\me\app\android\local.properties'.
  • No Android SDK found. Try setting the ANDROID_HOME environment variable.
  • Unable to locate Android SDK.
  • Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > SDK location not found.
In short

Gradle does not know where the Android SDK is installed. Put its path in android/local.properties with sdk.dir=..., or set the ANDROID_HOME environment variable, then open a new terminal and rebuild.

Be the first to confirm this fix

What this error means

The Android Gradle Plugin (AGP) needs the Android SDK (build-tools, platforms, platform-tools) to compile the app. When the build starts, it looks for its location in this order: the sdk.dir property in local.properties at the root of the Android project, then the ANDROID_HOME environment variable (and the legacy ANDROID_SDK_ROOT). If none is found, or the path points to a folder that does not exist, the build stops before compiling anything. It is very common on a freshly cloned project (local.properties is never committed), on a new machine, in CI, or when the build runs from a terminal that cannot see the variable.

Common causes

  1. Freshly cloned project: local.properties is ignored by Git, so it does not exist on your machine yet and ANDROID_HOME is not set.
  2. Variable set but not loaded: you added ANDROID_HOME to your shell profile, but the terminal, the IDE or the Gradle daemon were started before.
  3. SDK never installed: you installed Android Studio without finishing the first-run wizard, or only the command-line tools.
  4. Invalid path: sdk.dir points to an old location (another user, another machine) or contains unescaped backslashes on Windows.
  5. Build running in CI or Docker with no SDK installed and no ANDROID_HOME in the job environment.

Step-by-step fix

  1. Find the SDK path

    In Android Studio: Settings (macOS: Android Studio > Settings) > Languages & Frameworks > Android SDK, field "Android SDK Location". Default locations: macOS ~/Library/Android/sdk, Windows %LOCALAPPDATA%\Android\Sdk, Linux ~/Android/Sdk. Check that the folder contains platform-tools and platforms.

    bash
    # macOS
    ls ~/Library/Android/sdk
    # Linux
    ls ~/Android/Sdk
  2. Create local.properties (quick fix)

    Create local.properties in the Android folder of the project (android/ for React Native, Flutter or Capacitor, the root for a native Android project). On Windows, \ and : must be escaped in this file.

    ini
    # macOS
    sdk.dir=/Users/YOUR_USER/Library/Android/sdk
    # Linux
    sdk.dir=/home/YOUR_USER/Android/Sdk
    # Windows
    sdk.dir=C\:\\Users\\YOUR_USER\\AppData\\Local\\Android\\Sdk
  3. Set ANDROID_HOME (macOS / Linux)

    Lasting fix for all your projects: add the variable to your shell profile (~/.zshrc on macOS, ~/.bashrc on most Linux distributions), then open a new terminal.

    bash
    # ~/.zshrc (macOS) - on Linux use $HOME/Android/Sdk in ~/.bashrc
    export ANDROID_HOME="$HOME/Library/Android/sdk"
    export PATH="$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools"
  4. Set ANDROID_HOME (Windows)

    In PowerShell, save the variable for your user, then close and reopen the terminal and the IDE. You can also use "Edit environment variables for your account".

    powershell
    [Environment]::SetEnvironmentVariable("ANDROID_HOME", "$env:LOCALAPPDATA\Android\Sdk", "User")
  5. Install the SDK if it is missing

    If the folder does not exist, open Android Studio and finish the wizard (or More Actions > SDK Manager) to install an Android platform, Build-Tools and Platform-Tools. Without Android Studio, use sdkmanager from the Command-line Tools.

    bash
    sdkmanager "platform-tools" "platforms;android-35" "build-tools;35.0.0"
    sdkmanager --licenses
  6. Stop the Gradle daemon and rebuild

    The Gradle daemon keeps the old environment in memory. Stop it, then rebuild. For Flutter, also give the path to the tool and check with flutter doctor.

    bash
    cd android && ./gradlew --stop && cd ..
    npx react-native run-android
    
    # Flutter
    flutter config --android-sdk "$ANDROID_HOME"
    flutter doctor -v

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Set ANDROID_HOME once in your shell profile or Windows variables instead of recreating local.properties on every clone.
  • Keep local.properties in .gitignore: it contains machine-specific paths and would break your teammates’ builds.
  • In CI, use an image or action that provides the SDK (GitHub Actions Ubuntu runners already expose ANDROID_HOME) and document the expected platform version.

Frequently asked questions

ANDROID_HOME or ANDROID_SDK_ROOT?

ANDROID_HOME is the recommended variable today; ANDROID_SDK_ROOT is deprecated but still read. If you set both, they must point to the same folder.

Should I commit local.properties?

No. It contains the SDK path on your machine. Android Studio regenerates it automatically when you open the project.

Why does it work in Android Studio but not in the terminal?

Android Studio writes sdk.dir to local.properties or knows the SDK from its settings, while your terminal has no ANDROID_HOME. Add the variable to your shell profile and open a new terminal.

Useful tools for this error

More Mobile (Android, iOS) errors

All Mobile (Android, iOS) errors →