Install Flutter on Archlinux

Warning
This article was last updated on 08-04-2022, the content may be out of date.

/images/flutter_linux.png

Getting Flutter and Android working together is no small feat.

Linux may be a first-class citizen when it comes to developing with Flutter, but setting up Java, Android and the Android tool-chain can be a real hassle.

Android Studio is a fully-fledged IDE. If you want to use a different development editor (like Vim or VS Code), Android Studio is only good for eating space on your hard drive.

Arch Linux comes with the fabulous Arch package manager and the AUR, the Arch User Repository. The AUR offers dozens of useful packages which we can use to set up Android SDK.

Note
In this post, I will using Flutter (with YAY install) and Android Studio (AVD Manager) for Android Emulator.
Warning
You may need around 12 GB of free disk space for Flutter and Android SDK.
1
2
3
yay -S flutter
# accept the default
# (yay enables you to install AUR packages)

Create a new group flutterusers, add the default user to the group, then change permissions on the folder /opt/flutter.

The group may have been created beforehand so you may not need to do this. It’s no harm in doing it again anyway.

1
2
3
4
sudo groupadd flutterusers
sudo gpasswd -a $USER flutterusers
sudo chown -R :flutterusers /opt/flutter
sudo chmod -R g+w /opt/flutter/

If you still get permission denied errors, you can also change the permissions of the /opt/flutter folder to your $USER:

1
sudo chown -R $USER:flutterusers /opt/flutter
1
2
yay -S android-studio
# accept the default
Warning
After install Android Studio, make sure everything has default set up from Android Studio.

You must install needed tools like: Android SDK Command-Line-Tools and Android SDK Platform-Tools

/images/flutter_archlinux_needed_tools.png
You can install them in SDK Manager

Of course you can use Java 11 or higher for Flutter Development, but i recommend to use open-jdk8 because it’s stable now for Flutter

1
sudo pacman -S jdk8-openjdk
Tips

If you have other version of openjdk installed, you may have to change the default Java environments.

First, try checking your default environment by using:

1
archlinux-java status

The output look like this:

1
2
3
Available Java environments:
  java-15-openjdk
  java-8-openjdk (default)

If it’s not the case, then changing the environment:

1
sudo archlinux-java set java-8-openjdk
/images/flutter_archlinux_androidstudio.png
Now you can create Android Emulator easily with AVD Manager

Check if you have accepted all licenses:

flutter doctor --android-licenses

Then run flutter doctor.

The output will look like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 2.10.3, on Arch Linux 5.16.16-arch1-1, locale en_US.UTF-8)
[] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[] Android Studio (version 2021.1)
[] IntelliJ IDEA Community Edition (version 2021.3)
[!] Connected device
    ! No devices available
[] HTTP Host Availability

! Doctor found issues in 2 categories.

Flutter is successfully installed ^^

Again, if you get any trouble, feel free to contact me.

All rights and credits reserved to Ashpex.

I just rewrite and update the tutorials.