This guide installs the Android SDK to C:\Program Files (x86)\Android\android-sdk (Windows) and /Library/Android/sdk (macOS) using the Microsoft Build of OpenJDK.
The Android SDK Manager is a Java application. Using the Microsoft Build ensures long-term support and stability.
- Download: Go to the Microsoft OpenJDK Download Page.
- Version: Choose OpenJDK 17 (LTS).
- Installation:
- Windows: Run the
.msi. Crucial: Select the feature "Set JAVA_HOME variable" during the wizard. - macOS: Run the
.pkg.
- Windows: Run the
Navigate to the Android SDK tools guides and scroll to the bottom.
- Command line tools only: Download the zip for your OS (e.g.,
commandlinetools-win-xxxx_latest.zip). - SDK Platform-Tools: Download the "SDK Platform-Tools" zip (this contains
adb).
The SDK tools will not run unless they are nested inside a folder named latest.
- Root Folder: Create
C:\Program Files (x86)\Android\android-sdk. - Platform Tools: Extract
platform-tools-latest-windows.zipdirectly into the root.- Path:
...\android-sdk\platform-tools\adb.exe
- Path:
- Command Line Tools: * Create
...\android-sdk\cmdline-tools\latest.- Extract the contents of your command line tools zip into that
latestfolder. - Path:
...\android-sdk\cmdline-tools\latest\bin\sdkmanager.bat
- Extract the contents of your command line tools zip into that
- Root Folder: Create
/Library/Android/sdk. - Structure: Follow the same logic as Windows.
- Path:
/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager
- Path:
This is the "glue" that makes the tools work.
- Search for "Edit the system environment variables".
- Click Environment Variables.
- System Variables (New):
JAVA_HOME:C:\Program Files\Microsoft\jdk-17.x.x-hotspot(Verify your actual install path).ANDROID_HOME:C:\Program Files (x86)\Android\android-sdk
- Path Variable (Edit): Add these three lines:
%JAVA_HOME%\bin%ANDROID_HOME%\cmdline-tools\latest\bin%ANDROID_HOME%\platform-tools%ANDROID_HOME%\emulator
Open terminal, run nano ~/.zshrc, or open ~/.zshrc and add:
# Java Home (Microsoft OpenJDK)
export JAVA_HOME=/Library/Java/JavaVirtualMachines/microsoft-21.jdk/Contents/Home
# Android Home
export ANDROID_HOME=/Library/Android/sdk
# Update Path
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulatorSave (Ctrl+O, Enter) or (Ctrl+S) and Exit (Ctrl+X). Run source ~/.zshrc.
Now that the paths are set, finish the installation via terminal (Use Admin PowerShell on Windows).
# 1. Update tools
sdkmanager --update
# 2. Download Build-Tools and Platform (e.g., API 36)
sdkmanager "build-tools;36.0.0" "platforms;android-36"
# 3. Install an Android emulator
sdkmanager --install emulator
sdkmanager --install "system-images;android-36;google_apis;arm64-v8a"
avdmanager create avd -n AVD-API36 -k "system-images;android-36;google_apis;arm64-v8a"
# 4. Accept Licenses (The most important step)
sdkmanager --licenses
# 5. Launch the android virtual device
# emulator -avd AVD-API36Run these commands to ensure everything is perfect:
java -version(Should show Microsoft OpenJDK)echo %JAVA_HOME%(Windows) orecho $JAVA_HOME(Mac)adb version