Flutter Installation on Ubuntu

Flutter lets you build Android, iOS, web and desktop apps from one Dart codebase. Installing it on Ubuntu means setting up three things: the Flutter SDK itself, the Linux build tools it needs, and the Android SDK so you can compile for Android. This guide walks through the exact steps I used, includes the two real errors I hit (an old-Java JNI error from sdkmanager, and a missing Android SDK), and how each one was fixed.

1. Install Dependencies

These packages provide the compilers and libraries Flutter's Linux toolchain uses:

sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa clang cmake ninja-build libgtk-3-dev

2. Download the Flutter SDK

Download the latest stable Linux tarball from the official site, then extract it into a permanent location, e.g. ~/development/:

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

The extracted folder ~/development/flutter is your SDK root. Choose its location once — moving it later breaks Flutter's internal paths.

3. Add Flutter to Your PATH

Append the Flutter bin directory to your shell startup file so flutter works in every terminal, then reload it:

echo 'export PATH="$HOME/development/flutter/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

4. Check Flutter Doctor

flutter doctor reports what is installed and what is missing — run it before installing anything else:

flutter doctor

Expected output when everything is healthy (Android is the section to focus on):

[✓] Flutter (Channel stable, 3.27.4, on Linux)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] Connected device (1 available)

A [!] warning is usually non-blocking; a missing Android toolchain, however, prevents Android builds, which is why the next steps matter.

5. Install the Android SDK

sudo apt install android-sdk

6. Install the Command Line Tools

The modern Android SDK requires the cmdline-tools package (which contains sdkmanager), placed in a very specific directory structure:

mv cmdline-tools/ ~/development/
mkdir -p ~/development/android-sdk/cmdline-tools
mv ~/development/cmdline-tools ~/development/android-sdk/cmdline-tools/latest

The latest folder name is not cosmetic — sdkmanager refuses to run if the tools are not under cmdline-tools/latest.

7. Set ANDROID_HOME

echo 'export ANDROID_HOME=~/development/android-sdk' >> ~/.bashrc
source ~/.bashrc

8. Install Required SDK Packages

sdkmanager --install "cmdline-tools;latest" "platform-tools" "platforms;android-34" "build-tools;34.0.0"

9. Accept the Android Licenses

flutter doctor --android-licenses

Answer y for each license; without acceptance the toolchain will not build.

10. Verify the Setup

flutter doctor

You now have Flutter and the Android SDK correctly installed and configured.

Common Problems

Problem 1: "Error: A JNI error has occurred" when running sdkmanager

Error:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Cause: the Android tools are compiled with a recent Java (class file version 61.0 = Java 17), but the active java on your system is old (52.0 = Java 8). The tools simply refuse to load on an outdated runtime.

Solution: install a modern JDK and make it the active one — see the Java binary installation guide for JAVA_HOME and PATH setup, then verify: java -version should report 17 or newer.

Problem 2: "Android sdkmanager not found"

Error:

flutter doctor --android-licenses
Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.

Cause: the Android SDK or the cmdline-tools package is not installed on your machine — so there is no sdkmanager to call.

Solution: install the SDK and place cmdline-tools exactly under ~/development/android-sdk/cmdline-tools/latest as shown in steps 6–8, then re-run flutter doctor.

Problem 3: "git@github.com: Permission denied (publickey)" while using Flutter packages

Cause: your SSH key is not set up or not added to GitHub — Flutter plugins that are pulled from git over SSH fail for the same reason any git clone does.

Solution: verify whether you have a key:

ls -al ~/.ssh

If id_ed25519/id_ed25519.pub are missing, generate one:

ssh-keygen -t ed25519 -C "your-email@example.com"

Copy the public key to GitHub (Settings → SSH and GPG keys → New SSH Key):

cat ~/.ssh/id_ed25519.pub

Add it to the agent and test the connection:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh -T git@github.com

Success looks like this:

Hi user! You've successfully authenticated, but GitHub does not provide shell access.

Then retry the push:

git push --set-upstream origin master

For the complete setup (multiple keys, GitHub-specific config), see Configuring SSH Authentication for GitHub.

Best Practices

Conclusion

We installed the Linux dependencies, the Flutter SDK, added it to the PATH, set up the Android SDK with cmdline-tools and ANDROID_HOME, accepted the licenses, and verified everything with flutter doctor. The two errors along the way — the JNI failure and the missing sdkmanager — both traced back to environment state (old Java, missing SDK), not Flutter itself, which is why doctor is your best friend during setup.

Related Articles

A.M. Rinas

Written by A.M. Rinas

Full-Stack Software Engineer working on web applications, DevOps automation, and databases. More about me on the about page, or say hi through the contact page and LinkedIn.

← Back to all articles