Flutter Snapcraft.yaml

Hello guys,
I’m using flutter for my application. like the Flutter says, It was my snapcraft.yaml:

confinement: strict
base: core18
grade: stable

apps:
  aliyazdi75:
    command: my_site
    extensions: [flutter-master]
    plugs:
      - network

parts:
  aliyazdi75:
    source: .
    plugin: flutter
    flutter-target: lib/main.dart

but it gave me Failed to register: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied when I ran aliyazdi75 and after some searches from here I changed it to:

confinement: strict
base: core18
grade: stable

slots:
  dbus-aliyazdi75:
    interface: dbus
    bus: session
    name: io.github.aliyazdi75

apps:
  aliyazdi75:
    command: bin/my_site
    slots: [dbus-aliyazdi75]
    extensions: [flutter-master]
    plugs:
      - network

parts:
  aliyazdi75:
    source: .
    plugin: flutter
    flutter-target: lib/main.dart

After uploading .snap file says:

The Store automatic review failed.
A human will soon review your snap, but if you can't wait please write in the snapcraft forum asking for the manual review explicitly.
If you need to disable confinement, please consider using devmode, but note that devmode revision will only be allowed to be released in edge and beta channels.
Please check the errors and some hints below:
  - human review required due to 'deny-connection' constraint (interface attributes)

Why would I need to add dbus slot for my application, and how to fix this error:
human review required due to 'deny-connection' constraint (interface attributes)
Thanks in advance.

By default snaps are restricted from owning names on the D-Bus system and session buses. For example, imagine how your application would behave if some other application requested ownership of io.github.aliyazdi75 ahead of yours?

If you log in to the developer side of snapcraft.io, you should be able to navigate to your uploaded snap and request human review. This is a fairly simple case, so it is likely the request will be granted fairly quickly, and should allow future uploads to using the slot definition to pass automatic review.

Fair enough. So is the D-Bus system mandatory for all the flutter snapcrafts? And Flutter website should change the .yaml file template?
And how much longer does it take for this review to be done?

Hey @aliyazdi75,

Thanks for your post and once again, apologize for the delay. Have you visited the flutter application guide from this forum? I see some differences against the flutter.dev sample guide that could be of help. I am not a flutter expert but will take a look at this dbus concern you have and will come back to you hopefully with a solution. If needed sample guides should be updated as well.

I suggest you work locally before pushing the snap to the store until you are sure about what your snap needs and why. You could start with devmode, and then switch to strict confinement once you get such understanding. Please see this video for further details.

I also suggest installing the snappy-debug snap, which will help you troubleshoot and even suggest interfaces your snap might need (I mentioned this tool and other docs in the other post you created).

1 Like

When the docs and examples were created this wasn’t a fatal error. We’re looking into fixing that in flutter to prevent the need for the slot definition. Having the definition is fine, but we’d rather you not need to do that if your app doesn’t specifically need dbus.

I’ve proposed a branch that changes the application to use the G_APPLICATION_NON_UNIQUE flag by default, which should stop it attempting to register on D-Bus. The application ID will still be available for other uses.

You can test this by changing linux/my_application.cc to:

 MyApplication* my_application_new() {
  return MY_APPLICATION(g_object_new(my_application_get_type(),
                                     "application-id", APPLICATION_ID,
                                     "flags", G_APPLICATION_NON_UNIQUE,
                                     nullptr));
 }

There are some issues I have to mention:
This is my application source code

  • As you can see, flutter-master has been specified but by running snapcraft, the stable version downloaded:
[   +7 ms] "build linux" is not currently supported.
[   +3 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
           #1      BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:43:7)
           #2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:977:18)
           #3      _rootRunUnary (dart:async/zone.dart:1198:47)
           #4      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
           #5      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
           #6      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
           #7      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
           #8      Future._completeWithValue (dart:async/future_impl.dart:529:5)
           #9      Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
           #10     _rootRun (dart:async/zone.dart:1190:13)
           #11     _CustomZone.run (dart:async/zone.dart:1093:19)
           #12     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
           #13     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
           #14     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
           #15     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
           #16     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
           #17     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
           
           
[ +267 ms] ensureAnalyticsSent: 262ms
[   +7 ms] Running shutdown hooks
[   +1 ms] Shutdown hooks complete
[   +6 ms] exiting with code 1
Failed to run 'flutter build linux --release -v -t lib/main.dart' for 'aliyazdi75': Exited with code 1.
Verify that the part is using the correct parameters and try again.
  • Then I have to change it manually by snapcraft --debug and running flutter channel master, flutter upgeade, flutter config --enable-linux-desktop
  • Sometimes, by running snapcraft it says (I don’t know what’s the problem but it happens so randomly):
Could not find snap/snapcraft.yaml. Are you sure you are in the right directory?
To start a new project, use `snapcraft init`

and by checking the directory on VM, there is no snapcraft.yaml:

snapcraft-aliyazdi75 # ls
parts  prime  project  snap  stage  state
snapcraft-aliyazdi75 # cd snap/
snapcraft-aliyazdi75 ../snap# ls
flutter  snapcraft
snapcraft-aliyazdi75 ../snap# cd
snapcraft-aliyazdi75 # snapcraft init
Created snap/snapcraft.yaml.
  • I tried to build in confinement: devmode but faced a problem which I think related to url_launcher:
[ +172 ms] Building without sound null safety
[        ] For more information see https://dart.dev/null-safety/unsound-null-safety
[  +23 ms] Building Linux application...
[  +41 ms] executing: [build/linux/release/] cmake -G Ninja -DCMAKE_BUILD_TYPE=Release /root/parts/aliyazdi75/build/linux
[  +80 ms] CMake Error at flutter/generated_plugins.cmake:12 (add_subdirectory):
[   +2 ms]   add_subdirectory given source
[        ]   "flutter/ephemeral/.plugin_symlinks/url_launcher_linux/linux" which is not
[        ]   an existing directory.
[        ] Call Stack (most recent call first):
[        ]   CMakeLists.txt:51 (include)
[   +1 ms] -- Configuring incomplete, errors occurred!
[        ] See also "/root/parts/aliyazdi75/build/build/linux/release/CMakeFiles/CMakeOutput.log".
[  +34 ms] Building Linux application... (completed in 142ms)
[   +1 ms] "flutter linux" took 1,594ms.
[  +11 ms] Unable to generate build files
[   +1 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:12:3)
           #1      _runCmake (package:flutter_tools/src/linux/build_linux.dart:139:5)
           <asynchronous suspension>
           #2      buildLinux (package:flutter_tools/src/linux/build_linux.dart:72:5)
           <asynchronous suspension>
           #3      BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:49:5)
           <asynchronous suspension>
           #4      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1159:12)
           <asynchronous suspension>
           #5      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1011:27)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:152:19)
           <asynchronous suspension>
           #7      AppContext.run (package:flutter_tools/src/base/context.dart:151:12)
           <asynchronous suspension>
           #8      CommandRunner.runCommand (package:args/command_runner.dart:197:13)
           <asynchronous suspension>
           #9      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:280:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:152:19)
           <asynchronous suspension>
           #11     AppContext.run (package:flutter_tools/src/base/context.dart:151:12)
           <asynchronous suspension>
           #12     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
           <asynchronous suspension>
           #13     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:66:9)
           <asynchronous suspension>
           #14     run.<anonymous closure> (package:flutter_tools/runner.dart:64:12)
           <asynchronous suspension>
           #15     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:152:19)
           <asynchronous suspension>
           #16     AppContext.run (package:flutter_tools/src/base/context.dart:151:12)
           <asynchronous suspension>
           #17     runInContext (package:flutter_tools/src/context_runner.dart:75:10)
           <asynchronous suspension>
           #18     main (package:flutter_tools/executable.dart:92:3)
           <asynchronous suspension>
           
           
[ +263 ms] ensureAnalyticsSent: 253ms
[   +3 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1
Failed to run 'flutter build linux --release -v -t lib/main.dart' for 'aliyazdi75': Exited with code 1.
Verify that the part is using the correct parameters and try again.
  • After all, finally, I built and snapped in confinement: strict and install my application by --dangerous, and by running aliyazdi75 says:
Failed to register: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Connection ":1.177" is not allowed to own the service "io.github.aliyazdi75.my_site" due to AppArmor policy

@kenvandine Should I file these issues on flutter repository?

Hi @emitorino
Thank you so much and sorry that I created many topics :grinning:

Yes, I read all those topics and I summarized all steps I did, and as @kenvandine mentioned there’s no need to specify the DBus system.

1 Like

I submitted a PR to your repository which makes the dbus registration non-fatal. This will be the default behavior once the fix makes it into flutter.

I couldn’t build your app myself as “pub get” fails to find dependencies. But that’s unrelated.

2 Likes

Tanks @kenvandine and @robert.ancell, it’s fixed.

Yes, the problem was flutter_launcher_icons. I don’t know what that problem was. I just removed that.

But what about other things, should they be considered as issues?