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:
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:
Check that the tool is visible:
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:
That installs the package into:
Build Tools alone are not enough to compile an app, so you usually also install the matching platform and the platform tools:
Accept licenses non-interactively
On a fresh machine, sdkmanager may refuse to install until you accept the SDK 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:
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:
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:
That is enough for many builds and keeps the environment easy to reason about.
Mistakes that break the install
- Installing Build Tools before
sdkmanageris configured. Fix the command-line tools path first. - Installing only
build-toolswithoutplatformsorplatform-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.
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 for loop in reverse order 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 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 courseData 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.