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]
afterdeb
ordeb-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]
afterdeb
ordeb-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]
.