Skip to content

How to Fix Android SDK Not Found Error

DodaTech 2 min read

In this tutorial, you'll learn about How to Fix Android SDK Not Found Error. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

You try to build an Android project or run an ADB command and get:

Failed to find an Android SDK
Please ensure you have the Android SDK installed at the specified path

Or:

The ANDROID_HOME environment variable is not set

The Android SDK is missing, or the environment variables point to the wrong location.

Quick Fix

Step 1: Locate the Android SDK

Common installation paths:

~/Android/Sdk
/usr/lib/android-sdk
/opt/android-sdk
~/Library/Android/sdk  (macOS)
C:\Users\user\AppData\Local\Android\Sdk  (Windows)

Step 2: Set Android_HOME

export ANDROID_HOME=~/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin

Add these lines to ~/.bashrc or ~/.zshrc for persistence.

Step 3: Verify the environment variable

echo $ANDROID_HOME

Expected:

/home/you/Android/Sdk

Step 4: Verify ADB is accessible

adb --version

Expected:

Android Debug Bridge version 1.0.41
Version 35.0.2-12147442

Step 5: Install the SDK if missing

sudo apt update && sudo apt install android-sdk

For a more complete installation, use Android Studio:

  1. Download Android Studio from https://developer.Android.com/studio.
  2. Open SDK Manager > SDK Platforms and select the desired API levels.
  3. Open SDK Tools and select Android SDK Platform-Tools and Android SDK Build-Tools.

Step 6: Install command-line tools

wget https://dl.google.com/android/repository/commandlinetools-linux-latest.zip
unzip commandlinetools-linux-latest.zip -d ~/Android/Sdk
rm commandlinetools-linux-latest.zip

Then:

yes | ~/Android/Sdk/cmdline-tools/latest/bin/sdkmanager --licenses
~/Android/Sdk/cmdline-tools/latest/bin/sdkmanager "platforms;android-34" "build-tools;34.0.0" "platform-tools"

Step 7: Set Android_SDK_ROOT (alternative)

export ANDROID_SDK_ROOT=$ANDROID_HOME

Some tools use ANDROID_SDK_ROOT instead of ANDROID_HOME. Setting both covers all cases.

Step 8: Check for Gradle configuration

In Android/local.properties:

sdk.dir=/home/you/Android/Sdk

This file is generated by Android Studio but can be created manually.

Alternative Solutions

Use Android Studio's built-in SDK manager to install and manage SDK versions through the GUI.

Common Errors

ANDROID_HOME set but ADB not found: ANDROID_HOME points to the SDK root but platform-tools is not in the PATH. Update PATH: export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin.

sdkmanager: command not found: Install the command-line tools from Android Studio or download them directly from https://developer.Android.com/studio. The sdkmanager binary is in cmdline-tools/latest/bin/.

License not accepted: Run yes | ~/Android/Sdk/cmdline-tools/latest/bin/sdkmanager --licenses to accept all licenses. Without this, Gradle builds fail.

Insufficient disk space: The full Android SDK with multiple API levels can exceed 30 GB. Use sdkmanager to install only the platform versions you need.

Gradle does not find SDK even with ANDROID_HOME: Gradle reads local.properties in the project root, not the environment variable. Create or update Android/local.properties: sdk.dir=/home/you/Android/Sdk.

Multiple SDK installations conflict: If you have both Android Studio's SDK and a command-line installation, ensure only one ANDROID_HOME is set. Mixed installations cause unpredictable build errors.

Prevention

  • Set ANDROID_HOME and ANDROID_SDK_ROOT in your shell profile permanently.
  • Keep the SDK updated with sdkmanager --update.
  • Add platform-tools to PATH for adb access from any terminal.
  • Use the same SDK path across all projects for consistency.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro