Historically command-line tools for android were downloaded through the android developers webpage. When installed they were used to update other components. The problem with that was that there was no easy way to update command-line tools themself. This was now changed so that they are also distributed through SDK manager.
The issue at the moment is that, if you installed command-line tools through the old system, they won't get updated. So some changes are required for this to happen.
First, we need to install new cmdline-tools, through old sdkmanager.
sdkmanager "cmdline-tools;latest"
This will create $ANDROID_SDK_ROOT/cmdline-tools/latest
directory.
You could also specify a specific version (at the moment 1.0) instead of latest
. But then you would need to update $PATH
every time you update cmdline-tools.
If you run this command on JDK 9 or newer you will get an error java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
. To avoid this either downgrade to JDK 8 or install it through Android Studio.
Once new cmdline tools are installed you will still use the old ones as they are the ones specified in your $PATH
. To update that edit your ~/.zshrc
or ~/.bashrc
file and change from $PATH=$PATH...$ANDROID_SDK_ROOT/tools/bin...
to $PATH=$PATH...$ANDROID_SDK_ROOT/cmdline-tools/latest...
.
After that restart, you terminal and run which sdkmanager
. If output points to .../cmdline-tools/latest/bin
.