Android SDK
Build Tools
Command Line
Installation Guide
Software Development

How to install Android SDK Build Tools from the command line with sdkmanager

Codemia Knowledge Hub ·

Install the Android command-line tools package, make its sdkmanager available on your PATH, then run sdkmanager "build-tools;<version>". This works on headless machines and CI agents, with no need to open Android Studio.

Start with the Android command-line tools

You don't get Build Tools by downloading a loose ZIP. You first need the Android command-line tools package, because it contains sdkmanager.

A typical SDK layout looks like this:

text
1$ANDROID_SDK_ROOT/
2  cmdline-tools/
3  platform-tools/
4  build-tools/
5  platforms/

After downloading the command-line tools from the Android developer site, put them under cmdline-tools/latest so sdkmanager lives at a predictable path.

On macOS or Linux, for example:

bash
export ANDROID_SDK_ROOT="$HOME/Android/Sdk"
export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$PATH"

Check that the tool is visible:

bash
sdkmanager --version

If that fails, fix the SDK path before installing anything.

Install a specific Build Tools version

Once sdkmanager works, install the exact Build Tools revision you need:

bash
sdkmanager "build-tools;34.0.0"

That installs the package into:

text
$ANDROID_SDK_ROOT/build-tools/34.0.0

Build Tools alone are not enough to compile an app, so you usually also install the matching platform and the platform tools:

bash
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"

Accept licenses non-interactively

On a fresh machine, sdkmanager may refuse to install until you accept the SDK licenses:

bash
yes | sdkmanager --licenses

This comes up often in CI. If the licenses are not accepted, builds fail later with messages that look unrelated to installation.

Verify the installation

Confirm the package exists and that sdkmanager lists it:

bash
sdkmanager --list | grep "build-tools"
ls "$ANDROID_SDK_ROOT/build-tools"

With Gradle, you can also run a build and check that the configured Build Tools version is found. Modern Android builds often pick the right tooling from the installed packages automatically, but missing packages still fail the build immediately.

Which environment variable to set: ANDROID_HOME or ANDROID_SDK_ROOT

Both variables point to the SDK directory. Android's documentation recommends ANDROID_HOME and marks ANDROID_SDK_ROOT as deprecated; if you still set it, Android Studio and the Android Gradle plugin check that the two values agree. The examples here use ANDROID_SDK_ROOT, so substitute ANDROID_HOME for new setups.

A practical shell configuration on macOS or Linux:

bash
export ANDROID_SDK_ROOT="$HOME/Android/Sdk"
export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$PATH"
export PATH="$ANDROID_SDK_ROOT/platform-tools:$PATH"

On Windows, set the same variables through system environment variables or your PowerShell profile.

Install only what the project needs

Installing every available package wastes disk space and bloats CI images. Install the exact platform, Build Tools version, and extras the project requires. A project targeting API level 33 might need:

bash
sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.2"

That is enough for many builds and keeps the environment easy to reason about.

Mistakes that break the install

  • Installing Build Tools before sdkmanager is configured. Fix the command-line tools path first.
  • Installing only build-tools without platforms or platform-tools, which leaves the SDK incomplete for real builds.
  • Skipping license acceptance, which causes later failures that are easy to misread as Gradle or Java problems.
  • Pointing at the wrong SDK root, so packages land somewhere your build does not read.
  • Installing the latest Build Tools blindly, which can break older projects that expect a specific revision. Match the version to the project configuration.

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
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms