Error while building snapcraft flutter

My project works fine for iOS, Mac, Windows, Android, and local builds of Linux.

There seems to be a problem getting the snapcraft to work on linux builds. It tries to find a target that does not exist. I have my code on github—/bksubhuti/tipitaka-pali-reader I have uploaded the snap.yaml file I’m not sure what is going wrong. I can build locally without the arguments. I get the error that target does not exist.

] Target file "lib/main.dart for tipikata-pali-reader" not found.

The command that is generated from my snapcraft command that fails is:

flutter build linux --release -v -t lib/main.dart' for 'tipikata-pali-reader

Is there a way to solve this. I used core18 but I think that makes no difference since snap is always up to date.

Furthermore, My project uses sqlflite. In order to make this work on my own desktop, I need the following library libsqlite3-dev

I’m quite sure this will be an issue if the project ever builds.

1 Like

you still seem to be using a core18 base with the old plugin, try switching to core20, drop the plugin to nil and instead use the flutter build-snap like in:

Okay… i’ll try that tomorrow when I get wifi. or maybe try with a digitalocean server.

I’ll report back.
This is very resource intensive for Myanmar users.

Will it detect the libraries I use and include them… like the libsqlite3-dev needed for sqlite ? It is not included in standard installs and if It is a snap, I cannot tell the users to install it.

as long as you define libsqlite3-dev as a build-package and its binary package (libsqlite3-0) as stage-package your code will be built against the -dev and run against the staged runtime lib.

Where do i find the instructions on how to do stage-package and build-package? I have a DO server now. I can try.

The sample for supercoolapp still says core18 I think that it will not make a difference. If I have ubuntu 18 or ubuntu 22 the snap will be the same.

I changed to

confinement: strict
base: core20
grade: stable
icon: snap/gui/icon.png

parts:
  tipikata-pali-reader:
    source: .
    plugin: nil
    flutter-target: lib/main.dart # The main entry-point file of the application

I don’t know… this fails with core20

The sample on the flutter doc is done with core18 I’m just not a happy person with snap.
Looking to do AppImage instead. Electron Snap was not even 5% painful as this. Something has to give… there is no purpose in this overhead. AppImage has zero overhead…

If you respond… I’ll keep my DO server going… but this is terrible.

I used DO and typed this to launch. snapcraft --use-lxd

Error is this:

snapd" switched to the "latest/stable" channel

core20 20220527 from Canonical✓ installed
"core20" switched to the "latest/stable" channel

snapcraft 7.1.3 from Canonical✓ installed
"snapcraft" switched to the "latest/stable/ubuntu-22.04" channel

Failed to load extension 'flutter-stable': this extension does not support the 'core20' base.
Either use a different extension, or use a base supported by this extension.
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.
root@subhuntu:~/git/tipitaka-pali-reader#

https://odilondamasceno.medium.com/creating-appimage-with-flutter-d19ef8b53158

This works… (or at least on my machine), but I bet I would have the same problem with snaps or worse. I can tell people to manually install such and such files… I don’t think that is possible in snap.

I think the users will prefer AppImage just as much as the developers.

I will keep the DO server for one or two days… but I actually didn’t even get to the flutter install part because core20 does not support.

well, read the snapcraft.yaml i linked to, indeed you can not mix core18 and core20 plugins or extensions.

use the gnome-3-38 extension instead …

to add any files you want shipped with your app you need to add a stage-packages entry and list the debs you want to be included in your part, below is the reference:

okay… i tried that suggestion by replace core20 with gnome-3-38

I got this error.

Launching a container. Project base changed from ‘core20’ to ‘gnome-3-38’, cleaning first. The ‘LXD’ provider does not support base ‘gnome-3-38’

I’ve got AppImage working. The only loss with no snap is the store presence. However, 99% of people who would use our app would know about our app through other channels.

However, I think this is a loss for snap and flutter. I will try to build the sample app which does use core18 (full circle). Then I will try to see what the issue is. As far as I know, the issue is the command line that snapcraft generates… which is wrong . You can find in the original post in this thread. It might be that the pubspec yaml has a different name than the generated output for snap.

gnome-3-38 is not a base, it is an extension. See https://snapcraft.io/docs/snapcraft-extensions for a description of what an extension is and how to use one.

I give up and join the rest of the AppImage praising world. Perhaps all of this overhead is good so one can build remotely… but I’m building remotely and it does not work.

Building Electron snaps with electron-builder was easy and I could do locally in single digit minutes. I have no idea why this has to be so difficult. If you know someone in charge. Please send this link. Upon my exit, I will ask that question (why so difficult) in a new thread.
I will delete my DO server I created for this purpose because my local machine and bandwidth can only do this one time.

If anyone wants to give a try, you can download the git here I think it might be that the app name in the pubspec.yaml is different from snapcraft.yaml

If you want to try, you need to download the database here and then extract into assets/database and then run the split.sh script

best of luck… my original snapcraft.yaml from earlier this week made it to the build command., but snapcraft generated the wrong command and it does not get run. You can check the github to see variations of the file.
Let me know if it works… if not I will drop this for a long time.

Hi @bksubhuti

I am not from the snapped developer team, I am just snap enthusiast.

I am adding a link to my flutter snapcraft project in case you want to look at another working example

I appreciate your response. I see you are using core18 and also flutter-stable which is in the tutorial. I see that source is the git. our code cannot build directly from git because of the attached db. However, I wonder if that was the problem since i have a single “.” for my source.

I will look into this in a few weeks time. I’m busy making a release page and maybe video as well as many other items not related to this app. AppImage is suitable enough to say we support all devices and AppImage is super fast. I’m not so sure about how the snap will perform if I get there.

Now the snap thing is more like a challenge rather than a necessity. I’ll get back here later when I try again…

2 Likes