This guide explains how to set up the Android SDK and essential tools on Linux without installing Android Studio. We will be using the command-line tools only.
Android development requires the Java Development Kit (JDK). JDK 17 is generally recommended for modern Flutter and Android development.
sudo apt update
sudo apt install openjdk-17-jdk -yVerify the installation:
java -versionYou only need the Android Command Line Tools, instead of the entire Android Studio IDE package.
- Go to the Android Studio Downloads page and locate the "Command line tools only" section.
- Download the Linux
.zipfile. - Alternatively, you can download it via
wget(make sure to use the latest version link from the website):
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O cmdline-tools.zipThe SDK tools expect a very specific directory structure (cmdline-tools/latest/bin).
# Create the Android SDK home directory inside your user folder
mkdir -p ~/android-sdk/cmdline-tools
# Extract the contents of the downloaded zip
unzip cmdline-tools.zip -d ~/android-sdk/cmdline-tools
# Rename the extracted 'cmdline-tools' folder to 'latest'
mv ~/android-sdk/cmdline-tools/cmdline-tools ~/android-sdk/cmdline-tools/latestYou need to add the Android SDK paths to your system's environment variables. Open your shell configuration file (e.g., ~/.bashrc or ~/.zshrc) and add the following lines at the end:
export ANDROID_HOME=$HOME/android-sdk
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulatorApply the changes to your current terminal session:
source ~/.bashrc # or source ~/.zshrc if you use zshBefore installing any packages, you must accept the Android SDK licenses:
yes | sdkmanager --licensesUse the sdkmanager to install the essential platform-tools, build-tools, and the Android platform version you want to target (e.g., Android 34 / Android 14).
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"(Optional) If you plan to create and use Android Emulators locally, you also need the emulator and system images:
sdkmanager "emulator" "system-images;android-34;google_apis;x86_64"Finally, point your Flutter installation to the newly created Android SDK directory:
flutter config --android-sdk ~/android-sdkRun flutter doctor to ensure that Flutter recognizes your Android toolchain:
flutter doctorIf Flutter prompts you to accept any remaining Android licenses, run:
flutter doctor --android-licenses