Install Flame audio package crash project if you run with linux
Current bug behaviour
Installing the flame_audio package from pub.dev causes a crash if you run the project on linux.
It works again when uninstalling the package.
Expected behaviour
install the package normally.
Steps to reproduce
- Create a flutter project
- Install flame_audio package
- Run project on linux
Flutter doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on Ubuntu 20.04.4 LTS 5.15.0-43-generic, locale es_ES.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Android Studio
[✓] IntelliJ IDEA Ultimate Edition (version 2022.2)
[✓] VS Code (version 1.70.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
• No issues found!
More environment information
Log information
CMake Error at flutter/ephemeral/.plugin_symlinks/audioplayers_linux/linux/CMakeLists.txt:5 (include):
include could not find load file:
FetchContent
CMake Error at /snap/flutter/126/usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:419 (message):
A required package was not found
Call Stack (most recent call first):
/snap/flutter/126/usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:597 (_pkg_check_modules_internal)
flutter/ephemeral/.plugin_symlinks/audioplayers_linux/linux/CMakeLists.txt:25 (pkg_check_modules)
Exception: Unable to generate build files
That is this issue: https://github.com/bluefireteam/audioplayers/issues/1197
If I remember correctly Ubuntu based distros bundle a ridiculously old cmake version.
nmarafo I think you should install flutter manually instead of using snap if you are using a Linux distro thats because snap doesn't have proper CMake support.
Thank you very much for the reply. I'll try to do the manual installation to see if that fixes it. Greetings.
I think that you should also be able to get it working by install it from snap too if you manually set the channel:
snap refresh --channel=edge/core20 flutter
Since that is using this PR https://github.com/canonical/flutter-snap/pull/61
Thanks Lukas, but it didn't work for me... I tried to install Flutter manually but it keeps getting the path of the old installation. I hope it will be fixed when I upgrade to Ubuntu 22...
Did you make sure that it was fully uninstalled first?
I followed these steps:
$ sudo snap remove flutter
$ sudo snap install flutter --classic
$ flutter sdk-path
$ snap refresh --channel=edge/core20 flutter
but doesn't work
I'm not fully aware of how snap works, but shouldn't you set the channel before you install, otherwise you'll just install the same version again?
If I uninstall flutter before updating snap --channel=edge/core20 flutter
I get the message snap "flutter" is not installed.
I have reinstalled flutter again with sudo snap install flutter --classic --channel=edge/core20.
Also refresh channell and install flutter...
Maybe it's related to this issue?... https://github.com/Dart-Code/Dart-Code/issues/2791
@nmarafo could you try again now? Since https://github.com/canonical/flutter-snap/pull/61 is merged I'm hoping that it would work now.
Hi @spydon, after refresh with snap refresh --channel=edge/core20 flutter, I get the following error message:
CMake Error at /snap/flutter/127/usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:463 (message):
A required package was not found
Call Stack (most recent call first):
/snap/flutter/127/usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:643 (_pkg_check_modules_internal)
flutter/ephemeral/.plugin_symlinks/audioplayers_linux/linux/CMakeLists.txt:25 (pkg_check_modules)
flutter doctor it's OK.
Actually I'm working with Ubuntu 22.04.1 LTS
Since the channel has been merged now I don't think you should need to do that step.
Hey @nmarafo, on going to that particlular line in CMakeLists.txt, I found out that it was a gstreamer issue. Installing that in my system fixed this CMakeError. Btw, I am running Ubuntu 20.04 with manually build flutter and I'm using v1.4.0 release of flame engine.
Hi, @AmarNathH, thanks for your answer, If you are talking about install gstreamer I install this on my Ubuntu 22
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
but doesnt work. Where is the CMakeLists.txt issue?
Hey @nmarafo For this error,
flutter/ephemeral/.plugin_symlinks/audioplayers_linux/linux/CMakeLists.txt:25
You can see that there is an error at line 25 of CMakeLists, opening it and going to that line, you will able to find which package is missing.
In my console appear:
CMake Error at flutter/ephemeral/.plugin_symlinks/audioplayers_linux/linux/CMakeLists.txt:5 (include):
include could not find load file:
FetchContent
I have all gstreamer packages installed. In Stackoverflow say that "FetchContent" appear in CMake 3.11... any idea how repair?
At this point you got that CMakeLists error right? https://github.com/flame-engine/flame/issues/1836#issuecomment-1243615996
I am using the snap version of flutter, I've build it manually.
In Stackoverflow say that "FetchContent" appear in CMake 3.11... any idea how repair?
Can you run cmake --version and check what version you are using?
In my system I have
cmake --version
cmake version 3.22.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
If in flutter/ephemeral/.plugin_symlinks/audioplayers_linux/linux/CMakeLists.txt I change
cmake_minimum_required(VERSION 3.10)
to
cmake_minimum_required(VERSION 3.11)
I get this out:
CMake Error at flutter/ephemeral/.plugin_symlinks/audioplayers_linux/linux/CMakeLists.txt:2 (cmake_minimum_required):
CMake 3.11 or higher is required. You are running version 3.10.2

Are you still running the Flutter snap package? Because they are the ones bundling old versions of cmake, so it doesn't matter if you have a newer version installed on your system.
If I were you I would just completely purge the snap package and install Flutter from the .tar.xz
Thanks all for your answers.... Indeed, the problem was when using the snap version. After installing Flutter manually, the version used in CMake is 3.22.1 (I imagine it takes the one from my system) while with snap it was 3.10 which does not support "FetchContent". After deleting the "build" folder, I do a build again and now it works. SOLVED!!!