How to install Android SDK Build Tools on the command line?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Android SDK Build Tools can be installed entirely from the command line, which is useful for headless machines, CI agents, and developers who do not want to open Android Studio just to provision a toolchain. The key utility is sdkmanager, which installs specific packages into your Android SDK directory.
Start With the Android Command-Line Tools
The Build Tools are not installed directly by downloading a random ZIP. First you need the Android command-line tools package, because that package contains sdkmanager.
A typical SDK layout looks like this:
After downloading the command-line tools from the Android developer distribution, place them under a cmdline-tools/latest directory so sdkmanager is available at a predictable path.
On macOS or Linux, for example:
Then verify the tool is visible:
If that command fails, fix the SDK path before trying to install any packages.
Install a Specific Build Tools Version
Once sdkmanager works, install the exact Build Tools revision you need.
That command installs the package into:
You often also need the matching platform package and platform tools:
This is a more realistic setup for actually building an app, because Build Tools alone are not enough for a full Android compilation pipeline.
Accept Licenses Non-Interactively
On fresh environments, sdkmanager may refuse to install until you accept the Android SDK licenses.
This is especially common in CI environments. If the licenses are not accepted, builds fail later with messages that look unrelated to installation even though the missing step was simply license acceptance.
Verify the Installation
After installation, confirm the package exists and that sdkmanager can list it.
If your project uses Gradle, you can also verify by running a build and checking that the configured build tools version is available. In modern Android builds, Gradle often selects the correct tooling automatically from the installed SDK packages, but missing packages still cause immediate failures.
Use the Right Environment Variables
Two environment variables commonly appear in Android CLI setups: ANDROID_SDK_ROOT and the older ANDROID_HOME. Current tooling generally expects ANDROID_SDK_ROOT, and that is the safer default for new setups.
A practical shell configuration on macOS or Linux often looks like this:
On Windows, the same idea applies through system environment variables or PowerShell profile configuration.
Install Only What the Project Needs
Many developers install every package available, which wastes disk space and makes CI images heavier than necessary. A better practice is to install the exact platform, build-tools version, and optional extras required by the project.
For example, a project targeting API level 33 might need:
That is enough for many builds and keeps the environment easier to reason about.
Common Pitfalls
- Trying to install Build Tools before
sdkmanageris configured correctly leads nowhere. Fix the command-line tools path first. - Installing only
build-toolsbut notplatformsorplatform-toolsleaves the SDK incomplete for real builds. - Forgetting to accept licenses causes later build failures that are easy to misdiagnose as Gradle or Java issues.
- Using the wrong SDK root path means packages install into a location your build does not read.
- Installing the latest Build Tools blindly can break older projects that expect a specific revision. Match the package version to the project configuration.
Summary
- Install Android Build Tools with
sdkmanager, not by manually copying random files. - Configure
ANDROID_SDK_ROOTand makesdkmanageravailable onPATHfirst. - Install the exact
build-toolsversion your project expects, along with required platforms and platform tools. - Accept SDK licenses explicitly, especially on new machines and CI agents.
- Verify the final SDK layout so builds use the packages you actually installed.
Related reading
- How to install Android SDK on Ubuntu?
- How to install Google Play Services in a Genymotion VM with no drag and drop support?
- How to Install Plugin in Android Studio
- How to integrate Cocoapods with a Swift project?
- How to integrate Flutter app with Python code
- How to intercept touches events on a MKMapView or UIWebView objects?
- How to iterate a loop with index and element in Swift
- How to iterate a loop with index and element in Swift
.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 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.