Armbian + Flutter

I know I’ve seen a few people asking about doing Flutter dev on one of these boards.

Flutter 3.0 (I’m using the master branch) works fine for Linux development out of the box, nothing special needed, just so long as you’re using a relatively recent branch.

It’s possible to make it work for Android as well, but because Google seems disinclined to release Android dev tools for non-x86 hosts, it takes a bit of work:

  • Install OpenJDK 11 (openjdk-11-jdk), qemu-user, and qemu-user-binfmt from the Ubuntu repositories, if they’re not already installed.

  • Enable amd64 in dpkg: sudo dpkg --add-architecture amd64

  • Update /etc/apt/sources.list and /etc/apt/sources.list.d/*.

    Armbian uses ports.ubuntu.com, and Ubuntu separates out ‘ports’ from their mainline, so we need to make sure repositories are appropriate configured for architectures.

    For sources.list, duplicate any lines which reference http://ports.ubuntu.com/ and change them to reference http://archive.ubuntu.com/ubuntu/ instead.
    Add a tag [arch=arm64] after deb or deb-src to all lines not for archive.ubuntu.com.
    Add a tag [arch=amd64] to all lines that are for archive.ubuntu.com.
    In all of the sources.list.d content, just add [arch=arm64] after deb or deb-src. If there is already an [arch] tag listed, just keep going.

  • Update your APT cache: sudo apt update

  • Install glibc for amd64: sudo apt install libc6:amd64

  • Install Android Studio. 2022.1.1 works fine.

  • Install the Android SDK using Android Studio.

  • Download the Android emulator. (It’s a dependency of SDK packages, whether or not we actually use it.) Due to breakage here, likely an architecture mismatch, the SDK manager won’t find the emulator, so we download it and install it manually:
    Grab the latest non-canary release of the emulator https://developer.android.com/studio/emulator_archive (31.1.15 for now) and extract it’s contents to $HOME/Android/Sdk.
    Extract emulator-package.zip (6.2 KB) into $HOME/Android/Sdk/emulator.
    Edit package.xml to change the <major>, <minor>, and <micro> tags to match the revision you downloaded if it wasn’t 31.1.15.

  • In your Flutter installation directory (I’m going to assume $HOME/flutter), you’ll need to make a few links:

    for i in $HOME/flutter/bin/cache/artifacts/engine/*/linux-x64; do
      pushd $i/..
      ln -s linux-x64 linux-arm64
      popd
    done
    

    These make it so that the Flutter runtime knows where to find it’s tools.

  • Extract the GLSL shaders into the Flutter runtime directory.

    Extract shader_lib.zip (9.5 KB) into $HOME/flutter/bin/cache/artifacts/engine/linux-arm64. This works around a packaging issue by the Flutter team where they left that directory out of the ARM64 artifacts.

I think that covers making it so that building for an Android target works. It seems to be working here, at least.

Changes since the original post:

  • GLSL shader files attached. This works around a packaging error.
  • Changed the [arch] tags above: apt was behaving, for me, as though armhf was preferred. I took armhf out of the list, leaving [arch=arm64].
1 Like

hi, sarah :slight_smile:

My Armbian env is under.

OS: Armbian (23.02.0-trunk.0178) aarch64
Host: Radxa ROCK 5B
Kernel: 5.10.110-rockchip-rk3588
Uptime: 6 hours, 40 mins
Packages: 1674 (dpkg)
Shell: bash 5.1.16
Resolution: 2560x1440
DE: GNOME 42.5
WM: Mutter
WM Theme: Adwaita
Theme: Yaru-dark [GTK2/3]
Icons: Yaru [GTK2/3]
Terminal: gnome-terminal
CPU: (8) @ 1.800GHz
Memory: 1391MiB / 15719MiB

and, selected ‘Ubuntu Wayland’ at login.

My flutter master channel occur compile error.

% flutter channel master
% flutter upgrade
% flutter create test
% cd test
% flutter run ### try to ‘–release’ and ‘–profile’ options, same too.
ERROR: Compilation to SkSL failed.
… many SkSL error logs …

% flutter --version
Flutter 3.7.0-23.0.pre.15 • channel master • https://github.com/flutter/flutter
Framework • revision 6f708305d5 (6 hours ago) • 2023-01-18 18:02:23 -0500
Engine • revision 290636c1cb
Tools • Dart 3.0.0 (build 3.0.0-122.0.dev) • DevTools 2.20.0

% flutter doctor ### now only linux env
[✓] Flutter (Channel master, 3.7.0-23.0.pre.15, on Armbian 23.02.0-trunk.0178 Jammy 5.10.110-rockchip-rk3588, locale ja_JP.UTF-8)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
flutter config --android-sdk to update to that location.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

! Doctor found issues in 3 categories.

but, My flutter stable channel is gd wk!!! why?

Right, I remember there being an error now with SkSL: they screwed something up in the build for ARM64. It was minor: GLSL source files that were needed in the distribution weren’t properly bundled.

The fix: copy shader_lib from the Flutter engine source to the build cache directory.

Extract shader_lib.zip (9.5 KB) into flutter/bin/cache/artifacts/engine/linux-arm64/ and that’ll take care of the SkSL issue above. (If you’d rather grab it yourself: https://github.com/flutter/engine/tree/main/impeller/compiler/shader_lib)

My flutter doctor results:

sarah@rock-5b:~$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.7.0-24.0.pre.1, on Armbian 23.02.0-trunk.0097 Jammy 5.10.110-custom, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.74.3)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!
1 Like

Wow!!! thx sarah :slight_smile:
master channel was also able to run.

your flutter doctor is full marks, its great !!

1 Like

For each one down the list:

  • Android toolchain: that’s the one I outlined above, primarily. (That also covers Android Studio.)
  • Chrome: Mostly, set CHROME_EXECUTABLE in your environment to point at Chromium: export CHROME_EXECUTABLE=/usr/bin/chromium or equivalent in your shell profile (~/.bashrc in my case).
  • VS Code: Microsoft is better at supporting arm64 than Google. :woman_shrugging: Download the deb from https://code.visualstudio.com/download and install it. Install the Flutter extension inside of it.

I’m also running on X11 instead: Synergy (a tool for keyboard & mouse sharing across desktops) doesn’t work under Wayland, and I use it quite a bit for dealing with multiple machines on my desk.

1 Like

Hey I have this issue android snapshot are not working they are built for x86 not for arm64

[https://github.com/flutter/flutter/issues/85434](http://target android_aot_release_android-arm failed #85434)

Check the version of Flutter you’re trying to install. As mentioned, I’ve installed out of the ‘master’ branch, since running on an arm64 host is a bit bleeding edge for the toolkit itself, it seems. If you’re installing a release or even a beta branch, the arm64 tools may not be there.

No I have used master branch

~/flutter/bin/cache/artifacts/engine/android-arm64-release/linux-arm64

This directory should have a file called gen_snapshot to build android app on Linux arm64. Where to get this file it’s not available in master channel.

I am running arm archlinux. Flutter is working fine with gtk3 but android tools and building apps for android does not work. I am new to development flutter for android. can you any one help me ? That would help a lot.