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.
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:
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.
Then reload the profile:
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_ROOTset to the SDK directory.' - '
ANDROID_HOMEset to the same value for compatibility with older tools.' - Add
platform-toolsandcmdline-tools\\latest\\bintoPATH.
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.
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.
Also log the environment in CI:
That makes failures easier to diagnose than relying on the generic error message alone.
Common Pitfalls
- Setting only
ANDROID_HOMEwhen the tool expectsANDROID_SDK_ROOT. Fix by defining both for compatibility. - Adding the SDK root to
PATHbut forgetting the tool subdirectories. Fix by addingplatform-toolsandcmdline-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
androidcommand 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, keepANDROID_HOMEfor compatibility, and add the correct tool directories toPATH. - Verify setup with
adbandsdkmanager, not just by rerunning the failing script. - Use
local.propertiesfor project-specific Gradle discovery when needed. - If a script expects the deprecated
androidbinary, update the script rather than forcing old SDK behavior.
Related reading
- Error Appstore connect Missing Purpose String in Info.plist File
- Error Could not find included file 'Generated.xcconfig' in search paths in target 'Runner
- Error CUICatalog Invalid asset name supplied null, or invalid scale factor 2.000000
- ERROR Error installing cocoapods ERROR Failed to build gem native extension
- Error calculating pi using the Chudnovsky algorithm - Java
- Error Cannot find module 'async_hooks' in NodeJs
- Error File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it
- error 'Flutter/Flutter.h' file not found when flutter run on iOS
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo 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 courseTrack 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.