Installing Flutter on Linux: Don’t Let ‘Dependency Hell’ Discourage You

Development tutorial - IT technology blog
Development tutorial - IT technology blog

Haunted by a Flutter Doctor Full of Red X Marks?

If you’ve just switched from Windows to Linux or are new to app coding, seeing a flutter doctor screen full of errors is a demoralizing experience. I once spent two whole weekends struggling with an Android Emulator that wouldn’t start. Even the Android license status unknown error kept appearing despite having Android Studio installed.

Setting up your environment on Linux can sometimes feel like solving a dependency hell matrix. Installing one thing leads to missing another. After fixing the PATH environment variable, Java is the wrong version. Don’t worry, I’ve compiled a standard process so you don’t have to repeat those mistakes.

Why Does Linux Often ‘Act Up’ When Installing Flutter?

In reality, Linux is extremely lightweight and stable for mobile development. However, beginners often stumble for three main reasons:

  • Permissions Management: Linux has strict hardware security. If you don’t add the user to the kvm group, the Emulator will run at a snail’s pace due to a lack of hardware acceleration.
  • Missing 32-bit Libraries: Many old tools in the Android SDK still require 32-bit libraries. Newer Ubuntu versions (from 22.04 onwards) often omit these packages for system optimization.
  • Hidden Configuration Files: Unlike Windows, there’s no GUI for everything; you must manually edit .bashrc or .zshrc. Just one extra space or a wrong slash and the flutter command will return “not found”.

Which Installation Method is the Most ‘Hassle-Free’?

There are currently three common paths, but each has its own ‘trap’:

  1. Using Snap: Just type sudo snap install flutter and it’s done. However, Snap runs in a sandbox (isolated) environment. It often fails to detect Android Studio or Chrome for debugging, which is extremely frustrating.
  2. Using Management Tools (fvm/asdf): Suitable for pros who need to switch Flutter versions constantly. If you’re just starting, this only makes things more complicated.
  3. Manual Installation from a tar.xz file: This is my recommended method. You have full control over the SDK location, it’s easy to update, and you don’t have to worry about permission errors when writing to system directories.

The ‘Proper’ Setup Steps to Get Your Code Running

1. Prepare Your ‘Tools’ (Dependencies)

Before downloading the SDK, pre-install the foundation libraries. Open your terminal and paste this command:

sudo apt-get update
sudo apt-get install -y curl git unzip xz-utils libglu1-mesa clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++6

Without these packages, you will never be able to compile Desktop applications or handle smooth graphics.

2. Install Flutter SDK and Configure PATH

Create a ~/development directory in your Home folder to store your code. Never install into /usr/bin or /opt. You would need sudo every time you upgrade the SDK, which is both unsafe and prone to file permission errors.

mkdir ~/development
tar xf ~/Downloads/flutter_linux_3.x.x-stable.tar.xz -C ~/development

Now for the key step: Add Flutter to your environment variables. If you use Zsh (default on newer Ubuntu), open ~/.zshrc:

nano ~/.zshrc
# Add this line to the end of the file
export PATH="$PATH:$HOME/development/flutter/bin"

Remember to run source ~/.zshrc so the system updates the new command immediately.

3. Handle Java and the Android Toolchain

The Android license status unknown error is usually due to missing Command-line Tools. Go to Android Studio, select SDK Manager > SDK Tools, then check Android SDK Command-line Tools (latest). This is the most common error that makes 90% of beginners give up.

Regarding Java, Flutter ‘gets along’ best with OpenJDK 17. Java 21 might be too new and cause Gradle to crash when building older projects.

sudo apt install openjdk-17-jdk
flutter doctor --android-licenses

Keep pressing y until it’s finished. If this step fails, double-check the Command-line Tools mentioned above.

4. Activate the KVM ‘Magic’ for the Emulator

If you open the Emulator and see /dev/kvm device: permission denied, you need to grant virtualization access. Run the following command and then mandatory LOGOUT for the system to recognize the new permissions:

sudo usermod -aG kvm $USER
sudo chown $USER /dev/kvm

When KVM is active, the Emulator will run 5-10 times smoother compared to regular software emulation mode.

Improving the Experience for Low-End Machines

Running both Android Studio and an Emulator on 8GB of RAM is a disaster. To make coding easier, you should:

  • Prioritize VS Code: It’s much lighter than Android Studio. Just installing the Flutter and Dart extensions is enough.
  • Debug on a Physical Device: Plug in a USB cable and enable USB Debugging on your phone. This doesn’t consume RAM and gives you the most realistic touch experience.
  • Use Scrcpy: This is a tool to stream your phone screen to your computer via USB. You’ll see your phone screen right on Linux without using a single MB of RAM for an Emulator.

When you run flutter doctor and see the line No issues found!, that’s when the creative journey begins. I hope these practical tips save you a few precious hours to focus on what matters most: Writing code.

Share: