How to Install Flutter for Android on Linux Without Android Studio

If you are a Linux user like me and prefer lightweight tools like VS Code over Android Studio, setting up Flutter and the Android SDK can be challenging. As a part-time developer at an ISP, I've faced this process recently on Fedora after reinstalling my PC. Here is a detailed guide to help you get Flutter up and running without the bloat.

Prerequisites

  1. Linux distribution (tested on Fedora and Arch)
  2. Basic knowledge of bash scripting

Step 1: Install JDK

Flutter and the Android SDK require a Java Development Kit (JDK). It is possible to use a JDK version installed using a package manager of your distribution, but I recommend downloading Eclipse Temurin JDK and using it as a local user installation.

You will have to find a JDK version, that is compatible with your Android SDK platform version. I was unable to find a proper compatibility table, but there is a bit of information in the Android docs.

Steps:

  1. Extract the downloaded files and move them to a permanent location, such as ~/.local/share/jdk.

  2. Update your .bashrc file:

    .bashrc
    VERSION="18.0.2.1+1"
    
    JDK_PATH="$HOME/.local/share/jdk/jdk-$VERSION"
    
    export PATH="$PATH:$JDK_PATH/bin"
    export JAVA_HOME="$JDK_PATH"
  3. Reload your shell:

    source ~/.bashrc

Step 2: Install Android SDK Command-Line Tools

Instead of installing Android Studio, download the Command-Line Tools.

Steps:

  1. Extract the tools and move them to ~/.local/share/android-sdk/cmdline-tools/latest (ensure the bin/ inside directory is correctly placed).

  2. Update your .bashrc file:

    .bashrc
    ANDROID_SDK_PATH="$HOME/.local/share/android-sdk"
    
    export PATH="$PATH:$ANDROID_SDK_PATH/cmdline-tools/latest/bin"
    export PATH="$PATH:$ANDROID_SDK_PATH/platform-tools"
    export PATH="$PATH:$ANDROID_SDK_PATH/emulator"
    export ANDROID_HOME="$ANDROID_SDK_PATH"
  3. Reload your shell:

    source ~/.bashrc
  4. Use the SDK manager to install essential components:

    yes | sdkmanager \
      "platform-tools" \
      "emulator" \
      "platforms;android-35" \
      "build-tools;35.0.0" \
      "system-images;android-35;google_apis_playstore;x86_64"
    
    yes | sdkmanager --licenses

    You can change the version of the components to the one you need. Also keep in mind, that Flutter can later install other components during builds.

Step 3: Install Flutter SDK

Download the Flutter SDK from the official website.

Steps:

  1. Extract the downloaded SDK to a directory like ~/.local/share/flutter.

  2. Update your .bashrc file:

    .bashrc
    export PATH="$PATH:$HOME/.local/share/flutter/bin"
  3. Reload your shell:

    source ~/.bashrc

Step 4: Verify Your Installation

  1. Check if Flutter and the Android SDK are correctly set up:

    flutter doctor
  2. Ensure that all dependencies are resolved.

Tips for Development

By following these steps, you can avoid the bloat of Android Studio and enjoy a streamlined development environment. If you encounter issues, feel free to comment or reach out!