1. Download the latest version of the android command line tools (https://developer.android.com/studio#downloads)
$ wget https://dl.google.com/android/repository/commandlinetools-<OS>-<version>_latest.zip
Note: Since you'll need to check the downloads page to get the latest version, you might as well download it there. Using wget
is more useful when writing scripts.
$ unzip commandlinetools-<OS>-<version>_latest.zip -d android-sdk
3. Move the contents of the cmdline-tools folder into a subdirectory called "latest" (see https://stackoverflow.com/a/61176718/11411686)
$ mkdir android-sdk/cmdline-tools/latest && mv android-sdk/cmdline-tools/* android-sdk/cmdline-tools/latest
Note: You can ignore the error about being unable to move "latest" into itself.
4. Add the cmdline-tools/latest/bin
folder to $PATH
so we can execute it without typing the full path each time
$ echo export PATH=\"$PWD/android-sdk/cmdline-tools/latest/bin:\$PATH\" >> ~/.bashrc
$ source ~/.bashrc
Note: We're adding that export command to ~/.bashrc
so that it will be part of our $PATH
every time we start bash. The second line just re-executes the ~/.bashrc
file so that we don't have to restart our current shell.
$ yes | sdkmanager --licenses