1 sdkmanager require Java 17
brew install openjdk@17
2 download Android SDK command line tools only
https://developer.android.com/studio?hl=en#command-line-tools-only
3 unzip command line tools
mkdir -p ~/Library/Android/sdk/
unzip ~/Downloads/commandlinetools-mac-11076708_latest.zip -d ~/Library/Android/sdk/cmdline-tools
mv ~/Library/Android/sdk/cmdline-tools/cmdline-tools ~/Library/Android/sdk/cmdline-tools/latest
echo 'export PATH=$HOME/Library/Android/sdk/cmdline-tools/latest/bin:$PATH' >> ~/.zshenv
source ~/.zshenv
sdkmanager
Usage: sdkmanager [--uninstall] [] [--package_file=] [...]
warning: sdkmanager
should be here, otherwise you will get error "flutter doctor error: Android sdkmanager not found."
# wrong
/Users/tom/Library/Android/sdk/cmdline-tools/bin/sdkmanager
# right
/Users/tom/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager
4 set env
vi ~/.zshenv
export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"
export PATH=~/Library/Android/sdk/cmdline-tools/latest/bin:$PATH
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
5 download android sdk by cli not Android Studio
notice: macOS Android Studio default Android sdk dir: ~/Library/Android/sdk
sdkmanager --list
sdkmanager emulator
sdkmanager platform-tools
sdkmanager "build-tools;35.0.0"
sdkmanager "platforms;android-34"
sdkmanager "system-images;android-34;default;arm64-v8a"
sdkmanager "sources;android-34"
sdkmanager --list_installed
if you don't set env ANDROID_SDK_ROOT
, you should use:
sdkmanager --sdk_root=$HOME/Library/Android/sdk --list
not --sdk_root=~/Library/Android/sdk
.