Issue
I'm trying to build a flutter app for raspberry.
The raspberry has href="https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2022-09-26/2022-09-22-raspios-bullseye-arm64.img.xz" rel="noreferrer">2022-09-22-raspios-bullseye-arm64.img.xz image as Operation System. The uname
is "Linux raspberrypi 5.15.61-v8+ #1579 SMP PREEMPT Fri Aug 26 11:16:44 BST 2022 aarch64 GNU/Linux
"
These are my steps:
pi@raspberrypi:~ $ flutter create my_app
Building flutter tool...
Waiting for another flutter command to release the startup lock...
Creating project my_app...
Running "flutter pub get" in my_app...
Resolving dependencies in my_app... (3.0s)
+ async 2.10.0
+ boolean_selector 2.1.1
+ characters 1.2.1
+ clock 1.1.1
+ collection 1.17.0
+ cupertino_icons 1.0.5
+ fake_async 1.3.1
+ flutter 0.0.0 from sdk flutter
+ flutter_lints 2.0.1
+ flutter_test 0.0.0 from sdk flutter
+ js 0.6.6
+ lints 2.0.1
+ matcher 0.12.14
+ material_color_utilities 0.2.0
+ meta 1.8.0
+ path 1.8.3
+ sky_engine 0.0.99 from sdk flutter
+ source_span 1.9.1
+ stack_trace 1.11.0
+ stream_channel 2.1.1
+ string_scanner 1.2.0
+ term_glyph 1.2.1
+ test_api 0.4.17
+ vector_math 2.1.4
Changed 24 dependencies in my_app!
Wrote 129 files.
All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev
But when I try to run the app I get this error
pi@raspberrypi:~/my_app $ flutter run
Launching lib/main.dart on Linux in debug mode...
ERROR: Compilation to SkSL failed.
/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag: warning: (version, profile) forced to be (460, core), while in source code it is (320, es)
/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag:9: error: '#include' : Included file not found. for header name: flutter/runtime_effect.glsl
/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag:93: error: 'FlutterFragCoord' : no matching overloaded function found
/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag:93: error: '=' : cannot convert from ' const float' to ' temp 2-component vector of float'
ERROR: Target debug_bundle_linux-arm64_assets failed: ShaderCompilerException: Shader compilation of "/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag" to "/home/pi/my_app/build/flutter_assets/shaders/ink_sparkle.frag" failed with exit code 1.
/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag: warning: (version, profile) forced to be (460, core), while in source code it is (320, es)
/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag:9: error: '#include' : Included file not found. for header name: flutter/runtime_effect.glsl
/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag:93: error: 'FlutterFragCoord' : no matching overloaded function found
/home/pi/snap/flutter/common/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag:93: error: '=' : cannot convert from ' const float' to ' temp 2-component vector of float'
Building Linux application...
Exception: Build process failed
This is my flutter doctor
pi@raspberrypi:~/my_app $ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.7.0-13.0.pre.31, on Debian GNU/Linux 11 (bullseye) 5.15.61-v8+, locale en_GB.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.
Solution
Here is the solution, after all it was quite simple. The error above was given because I was installing flutter on the raspberry via snap, when I tried cloning the repository it worked fine.
Here he left the steps:
#install prerequisites
sudo apt update && sudo apt install -y cmake ninja-build clang libgtk-3-dev git curl unzip
#to simplify more I have left it in the $HOME
cd $HOME
git clone https://github.com/flutter/flutter.git -b stable
sudo ln -s /home/pi/flutter/bin/flutter /usr/bin/
flutter doctor
flutter create my_app
cd my_app
flutter build linux
For docker lovers I have created a very basic image, here it is, docker pull jaimemanuelroman/flutter_ubuntu:bionic
. To work with it, you must map the folder where you want to create the project to /var/app
.
To create a project from scratch would be:
cd $HOME
mkdir my_app
docker run --rm -v /home/pi/my_app/:/var/app jaimemanuelroman/flutter_ubuntu:bionic bash -c "flutter create . && flutter build linux"
And when we go to $HOME/my_app/build/linux/arm64/release/bundle/
we will have our app compiled.
NOTE: I was only able to create the image to run on arm64/v8
pq on armv7l
, it gave an error. I could also build it for amd64
if someone needs it.
Answered By - Jaime Roman Answer Checked By - Willingham (WPSolving Volunteer)