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.
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.
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.
After editing the file, reload the shell:
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.
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.
Then run at least one real command:
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:
platform-toolsforadbemulatorfor the emulator binarycmdline-tools/latest/binforsdkmanagerand 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.
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:
- verify the binary exists where you think it does
- verify the profile file you edited was actually loaded
- verify no alias or older install is taking precedence
Useful diagnostics include:
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_HOMEandANDROID_SDK_ROOTand add the relevant tool directories toPATH. - Edit the startup file for the shell you actually use, usually
~/.zshrcon 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.

