Skip to content

Instantly share code, notes, and snippets.

@creallfluharty
Last active November 7, 2020 21:50
Show Gist options
  • Save creallfluharty/938351f77524107a4c06dbf3e7608575 to your computer and use it in GitHub Desktop.
Save creallfluharty/938351f77524107a4c06dbf3e7608575 to your computer and use it in GitHub Desktop.
Install the Android SDK on Linux

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.

2. Extract the tools into a folder which will hold the rest of the SDK

$ 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.

5. Accept the SDK licenses

$ yes | sdkmanager --licenses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment