i run docker pull cirrusci/flutter:stable
to get a clean docker with android and flutter installed
my system is an m1 mac with macOS 12.6 and
1m1@1m1s-MacBook-Air ~ % docker --version
Docker version 20.10.17, build 100c701
running docker run -it image_id /bin/bash
gives a warning:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
inside the docker, flutter --version
gives
root@74a20a5b7edf:/# flutter --version
Flutter 3.3.1 • channel unknown • unknown source
Framework • revision 4f9d92fbbd (10 days ago) • 2022-09-06 17:54:53 -0700
Engine • revision 3efdf03e73
Tools • Dart 2.18.0 • DevTools 2.15.0
the error comes here by running flutter doctor --android-licenses
:
root@74a20a5b7edf:/# flutter doctor --android-licenses
===== CRASH =====
si_signo=Segmentation fault(11), si_code=1, si_addr=0x7
version=2.18.0 (stable) (Fri Aug 26 10:22:54 2022 +0000) on "linux_x64"
pid=173, thread=217, isolate_group=main(0x400305f000), isolate=main(0x40030d6000)
isolate_instructions=4001ece300, vm_instructions=4001ece300
pc 0x0000ffffa600472b fp 0x00000040103d51f0 Unknown symbol
pc 0x0000ffffa4b37411 fp 0x00000040103d5228 Unknown symbol
pc 0x0000ffffa54561fd fp 0x00000040103d5268 Unknown symbol
pc 0x0000ffffa4b37248 fp 0x00000040103d52c8 Unknown symbol
pc 0x0000ffffa58672e9 fp 0x00000040103d5318 Unknown symbol
pc 0x0000ffffa5d7f3b3 fp 0x00000040103d5360 Unknown symbol
pc 0x0000ffffa5d7f02b fp 0x00000040103d53a0 Unknown symbol
pc 0x0000ffffa5d7ef59 fp 0x00000040103d53c8 Unknown symbol
pc 0x0000ffffa5d7ee7e fp 0x00000040103d5408 Unknown symbol
pc 0x0000ffffa5d22c38 fp 0x00000040103d5448 Unknown symbol
pc 0x0000ffffa6002a0c fp 0x00000040103d54c0 Unknown symbol
pc 0x00000040020464bd fp 0x00000040103d5560 dart::DartEntry::InvokeCode(dart::Code const&, unsigned long, dart::Array const&, dart::Array const&, dart::Thread*)+0x14d
pc 0x00000040020462fc fp 0x00000040103d55c0 dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)+0x14c
pc 0x000000400204872c fp 0x00000040103d5610 dart::DartLibraryCalls::HandleMessage(long, dart::Instance const&)+0x14c
pc 0x000000400206fda0 fp 0x00000040103d5ba0 dart::IsolateMessageHandler::HandleMessage(std::__2::unique_ptr<dart::Message, std::__2::default_delete<dart::Message> >)+0x350
pc 0x00000040020992cd fp 0x00000040103d5c10 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)+0x14d
pc 0x00000040020999af fp 0x00000040103d5c60 dart::MessageHandler::TaskCallback()+0x1df
pc 0x00000040021bc868 fp 0x00000040103d5ce0 dart::ThreadPool::WorkerLoop(dart::ThreadPool::Worker*)+0x148
pc 0x00000040021bccbd fp 0x00000040103d5d10 dart::ThreadPool::Worker::Main(unsigned long)+0x6d
pc 0x000000400212f488 fp 0x00000040103d5dd0 /sdks/flutter/bin/cache/dart-sdk/bin/dart+0x212f488
-- End of DumpStackTrace
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted
in fact, the Dockerfile (https://github.com/cirruslabs/docker-images-flutter/blob/master/sdk/Dockerfile) has flutter doctor --android-licenses
as the last RUN
cmd and hence fails to run to the end
in other experiments, flutter pub get
fails, trying to start with a clean debian
, using diff architectures
i have a feeling that the cirrusci/flutter is failing due to some problem connected with my system being arm/m1 (though my system is new/clean) ~ is the docker maybe not getting internet? but wget https://google.com
works ~ which port does flutter pub get
use? but even though i run an open docker docker run --network host
, the same error persists
ultimately, i am trying to setup ci for my flutter android app
what to do? why is cirrusci/flutter:stable
not working on m1?
As you noticed yourself, you are starting a docker build based on an image that was built for another platform, i.e. you are running arm64 but the image is linux/amd64.
This means that docker will run it but with an emulation layer, namely qemu
.
Some incompatibility between Dart and qemu seems to be the problem. In the stacktrace you posted, qemu crashed when Dart runtime tried to execute InvokeCode()
. This is actually a reported problem, see e.g.
The Dart folks have no plans to analyze this any further since the problem lies with qemu and the problem was not reproduced with qemu outside docker.
It is also noteworthy that docker with qemu is only provided as a best effort and the docker project itself is unlikely to tackle the issue either, even if reported.
I did not find a filed issue for qemu itself.
There are basically two options:
This will work to some degree regarding flutter, but the next thing you will have to tackle is arm-based android build for linux, which is a whole new can of worms. See e.g. google's android bug tracker, Please support Linux aarch64 for building apps and others.
As sad as it is to realize this, it might be the straightforward solution to not cross-build in this case, at least for flutter with android build target. And likely also a logical one if you want to provide an intel compatible docker image to coworkers and/or CI which might not run M1. Ultimately, it is a question what your reference build platform is.