Skip to content

Instantly share code, notes, and snippets.

@blazsolar
Last active February 27, 2020 09:21
Show Gist options
  • Save blazsolar/50f7936d31758330ee6dd059e0cb372b to your computer and use it in GitHub Desktop.
Save blazsolar/50f7936d31758330ee6dd059e0cb372b to your computer and use it in GitHub Desktop.

Command-line tools

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.

Installing new cmdline-tools

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.

Updating path

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment