Android SDK
Mac
PATH
Environment Variables
Development Setup

Finding Android SDK on Mac and adding to PATH

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

On macOS, Android Studio often knows where the Android SDK lives even when your shell does not. That is why adb can work inside the IDE while terminal commands fail with “command not found.” A proper setup finds the real SDK directory, exports the right environment variables, and verifies the tools in the shell you actually use.

Find the SDK Directory First

Do not edit PATH until you know the correct SDK location. The default user install path on macOS is usually under your home library folder.

bash
ls "$HOME/Library/Android/sdk"

If that directory does not exist, open Android Studio and check the SDK Manager path. You can also search for adb if the tooling is already installed somewhere on the machine.

bash
which adb || true
find "$HOME" -name adb -type f 2>/dev/null | head -5

Once you confirm the location, choose one canonical path and use it consistently across shell profiles, scripts, and CI jobs.

Export the SDK Variables for zsh

Modern macOS uses zsh by default, so the usual place for these exports is ~/.zshrc. Set both ANDROID_HOME and ANDROID_SDK_ROOT for broad compatibility, then prepend the important tool directories to PATH.

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

After editing the file, reload the shell:

bash
source ~/.zshrc

If you use another shell, put the same exports in the startup file that shell actually reads.

Confirm Which Shell You Are Using

A common reason setup fails is editing the wrong profile file. Check the current shell before troubleshooting further.

bash
echo "$SHELL"

If the output is /bin/zsh, changes to ~/.bash_profile will not affect your default terminal sessions. If you really do use bash, then ~/.bash_profile or ~/.bashrc may be the right place instead.

Verify the Tools, Not Just the Variables

Once the environment variables are set, validate both the values and the command resolution path.

bash
1echo "$ANDROID_HOME"
2which adb
3which emulator
4adb --version
5sdkmanager --version

Then run at least one real command:

bash
adb devices
emulator -list-avds

Version checks only prove the binary was found. A real command proves the tool runs successfully in your shell environment.

Understand Common Directory Choices

The Android SDK usually contains several subdirectories, but only some of them need to be in PATH regularly:

  1. platform-tools for adb
  2. emulator for the emulator binary
  3. cmdline-tools/latest/bin for sdkmanager and related tools

You do not need to add every SDK folder. Adding only the command directories keeps PATH cleaner and makes tool resolution easier to debug.

Keep Local Setup and Automation Consistent

Shell startup files help interactive development, but CI and automation often run in non-interactive shells that do not load the same profile files. In automation, export the variables directly in the job step.

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

This makes the job deterministic and avoids depending on user-specific shell behavior.

Diagnose “Command Not Found” Methodically

If adb still does not resolve, check the path in order:

  1. verify the binary exists where you think it does
  2. verify the profile file you edited was actually loaded
  3. verify no alias or older install is taking precedence

Useful diagnostics include:

bash
type adb
ls -l "$ANDROID_HOME/platform-tools/adb"
printenv | grep ANDROID

If type adb points somewhere unexpected, reorder PATH so the intended SDK directory comes first.

Common Pitfalls

The most common mistake is editing ~/.bash_profile while using zsh. Another is exporting only the SDK root and forgetting to add platform-tools or cmdline-tools to PATH. Developers also assume Android Studio path settings automatically configure terminal sessions, which they do not.

Summary

  • Confirm the real Android SDK location before editing environment variables.
  • Set ANDROID_HOME and ANDROID_SDK_ROOT and add the relevant tool directories to PATH.
  • Edit the startup file for the shell you actually use, usually ~/.zshrc on modern macOS.
  • Verify the setup with both version checks and real commands such as adb devices.
  • Export the same variables explicitly in CI so automation does not depend on interactive shell config.

Course illustration
Course illustration

All Rights Reserved.