Android Development
ANDROID_HOME
PATH Environment Variable
Android SDK
Error Troubleshooting

Error ANDROID_HOME is not set and android command not in your PATH. You must fulfill at least one of these conditions.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

This error means your build tooling cannot find the Android SDK location or the command-line binaries it expects. It often appears in Gradle, React Native, Cordova, and older Android automation scripts. The practical fix is to point the environment at the actual SDK location, add the right tool directories to PATH, and verify whether the failing script still expects deprecated Android CLI commands.

Why the Error Appears

Android-related tools look for the SDK in a few conventional places:

  • 'ANDROID_HOME'
  • 'ANDROID_SDK_ROOT'
  • project-level local.properties
  • directories listed in the shell PATH

If those are missing, incorrect, or stale, the build script cannot find SDK tools and fails early.

Older scripts may also specifically look for the old android command, which is deprecated in modern SDK distributions. In those cases, the environment may be correct but the script itself is outdated.

Modern SDK Paths You Usually Need

Recent Android installations are built around:

  • The SDK root directory.
  • 'platform-tools'
  • 'cmdline-tools/latest/bin'

Those are the paths that normally need to be discoverable.

Typical validation commands:

bash
adb version
sdkmanager --list

If both commands work in the same shell where your build fails, the environment is at least partially correct.

macOS and Linux Setup

On macOS or Linux, export the variables in your shell profile such as .zshrc or .bashrc.

bash
1export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
2export ANDROID_HOME="$ANDROID_SDK_ROOT"
3export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools"
4export PATH="$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin"

Then reload the profile:

bash
source ~/.zshrc

On Linux, the SDK path is often $HOME/Android/Sdk instead of the macOS location.

Windows Setup

On Windows, configure environment variables through system settings or a shell profile used by your tooling.

Recommended values:

  • 'ANDROID_SDK_ROOT set to the SDK directory.'
  • 'ANDROID_HOME set to the same value for compatibility with older tools.'
  • Add platform-tools and cmdline-tools\\latest\\bin to PATH.

After updating environment variables, open a new terminal session before retesting. Existing shells do not automatically pick up the changes.

Project-Level Fallback with local.properties

Many Android projects also read the SDK location from local.properties.

properties
sdk.dir=/Users/yourname/Library/Android/sdk

This is especially useful when Gradle can find the SDK for the project even if the general terminal environment is incomplete. It does not replace shell setup for all tools, but it often resolves project-specific build failures.

The Deprecated android Command Problem

The old android command-line tool is no longer part of modern Android SDK command-line tooling. Some legacy scripts still check for it and then emit this error message.

In that case, the real fix is not just setting ANDROID_HOME; it may also require updating the script to use newer tools such as:

  • 'sdkmanager'
  • 'avdmanager'
  • Gradle tasks

If a third-party package expects the old android binary, patching or upgrading that package is often the right move.

CI and Container Environments

CI is where this error shows up most often because the environment is created from scratch each run. Make SDK paths explicit in pipeline config.

bash
export ANDROID_SDK_ROOT="$HOME/android-sdk"
export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin"
./gradlew assembleDebug

Also log the environment in CI:

bash
echo "$ANDROID_SDK_ROOT"
which adb
which sdkmanager

That makes failures easier to diagnose than relying on the generic error message alone.

Common Pitfalls

  • Setting only ANDROID_HOME when the tool expects ANDROID_SDK_ROOT. Fix by defining both for compatibility.
  • Adding the SDK root to PATH but forgetting the tool subdirectories. Fix by adding platform-tools and cmdline-tools/latest/bin.
  • Updating shell profiles without opening a new shell. Fix by reloading the profile or starting a fresh terminal session.
  • Assuming the old android command still exists in modern SDKs. Fix by updating legacy scripts to use current command-line tools.
  • Making local machine fixes without matching CI configuration. Fix by documenting and reproducing the environment in automation.

Summary

  • This error means the Android SDK path or Android command-line tools are not discoverable.
  • Set ANDROID_SDK_ROOT, keep ANDROID_HOME for compatibility, and add the correct tool directories to PATH.
  • Verify setup with adb and sdkmanager, not just by rerunning the failing script.
  • Use local.properties for project-specific Gradle discovery when needed.
  • If a script expects the deprecated android binary, update the script rather than forcing old SDK behavior.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions