macOS(via Homebrew)

sw_vers
# ProductName: Mac OS X
# ProductVersion: 10.15.4
brew tap caskroom/cask
brew cask install homebrew/cask-versions/adoptopenjdk8
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
brew cask install android-sdk
sdkmanager --list | awk '/Installed/{flag=1; next} /Available/{flag=0} flag'

Error: NoClassDefFoundError

sdkmanager --list
# Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

Fix:

brew cask install homebrew/cask-versions/adoptopenjdk8
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

macOS(manual way)

  1. download Android Command line tools
mkdir -p ~/code/android_sdk/cmdline-tools && cd "$_"
unzip ~/Downloads/commandlinetools-mac-6200805_latest.zip
  1. set env
export ANDROID_SDK_ROOT="$HOME/code/android_sdk"
export PATH="$PATH:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/tools/lib:$ANDROID_SDK_ROOT/platform-tools"
  1. install tools
./tools/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install tools
  1. install Java 1.8
brew cask install homebrew/cask-versions/adoptopenjdk8
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
sdkmanager --list

Warning: Could not create settings

android_sdk/tools/bin/sdkmanager --list   
# Warning: Could not create settings
# java.lang.IllegalArgumentException
#	at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)

Fix:

mkdir -p cmdline-tools
mv android_sdk/tools android_sdk/cmdline-tools/
android_sdk/cmdline-tools/tools/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install tools
ls -l android_sdk/tools/bin/sdkmanager

Warning: Observed package in inconsistent location

android_sdk/cmdline-tools/tools/bin/sdkmanager --sdk_root=../ --list
# Warning: Observed package id 'tools' in inconsistent location '../cmdline-tools/latest' (Expected '../tools')

Fix:

android_sdk/cmdline-tools/tools/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install tools
android_sdk/tools/bin/sdkmanager --list