Hi all! I’m new here. I use to create apps for Ubuntu mobile. Few weeks ago I started learning Flutter.
Yesterday I’ve seen the news about Flutter and Canonical working together to allow snapping Flutter apps.
Today I’ve made a snap for one of my Flutter project. It’s very simple but my problem is the size of the snap. It’s more than 22MB whereas the snap for Flokk app (which is much more complicated) is about 17MB. So my question is: How can I reduce size of the snap?
My app: https://snapcraft.io/color-match
Source code: https://github.com/mivoligo/color-match
That is great to hear!
I’m looking at your snap and there’s an asset getting included in your snap that is not in the flokk-contacts snap. I’m going to figure out why, thanks for pointing it out.
You are getting a debug build, but I’m not sure how. Snapcraft’s flutter plugin builds in release mode. What version of snapcraft are you using?
I had to create new account as I’m not able to post anything from @mivoligo on this forum.
Anyway, my snapcraft version is 4.1.1
Same version I have. When I built your snap it’s 15M and it’s built in release mode. Really not sure how you’re getting a debug build.
This is what’s going on when I run snapcraft
command:
michal@michal-laptop:~/AndroidStudioProjects/color_match$ snapcraft Launching a VM. The flutter plugin is currently in beta, its API may break. Use at your own risk. snapd is not logged in, snap install commands will use sudo snap “core18” has no updates available Updating pull step for color-match (source changed) Skipping pull flutter-extension (already ran) Skipping pull gnome-3-28-extension (already ran) Updating build step for color-match (‘pull’ step changed) flutter pub get Woah! You appear to be trying to run flutter as root. We strongly recommend running the flutter tool without superuser privileges. /
Running “flutter pub get” in build… 0.7s flutter build linux --release -v -t lib/main.dart Woah! You appear to be trying to run flutter as root. We strongly recommend running the flutter tool without superuser privileges. /
[ +166 ms] executing: [/root/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H [ +46 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 –pretty=format:%H [ ] 61a04b1551a8f63b3081267dc7a0bbc16a1b4bf5 [ ] executing: [/root/snap/flutter/common/flutter/] git tag --contains HEAD [ +216 ms] Exit code 0 from: git tag --contains HEAD [ +2 ms] executing: [/root/snap/flutter/common/flutter/] git describe --match ..-..pre --first-parent --long --tags [ +16 ms] Exit code 0 from: git describe --match ..-..pre --first-parent –long --tags [ ] 1.20.0-2.0.pre-193-g61a04b155 [ +11 ms] executing: [/root/snap/flutter/common/flutter/] git rev-parse –abbrev-ref --symbolic @{u} [ +5 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u} [ ] origin/master [ ] executing: [/root/snap/flutter/common/flutter/] git ls-remote –get-url origin [ +5 ms] Exit code 0 from: git ls-remote --get-url origin [ ] https://github.com/flutter/flutter.git [ +58 ms] Unable to locate an Android SDK. [ +18 ms] executing: [/root/snap/flutter/common/flutter/] git rev-parse –abbrev-ref HEAD [ +18 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD [ ] master [ +141 ms] Artifact Instance of ‘AndroidMavenArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘AndroidGenSnapshotArtifacts’ is not required, skipping update. [ ] Artifact Instance of ‘AndroidInternalBuildArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘IOSEngineArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘FlutterWebSdk’ is not required, skipping update. [ +5 ms] Artifact Instance of ‘WindowsEngineArtifacts’ is not required, skipping update. [ +3 ms] Artifact Instance of ‘MacOSEngineArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘LinuxEngineArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘LinuxFuchsiaSDKArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘MacOSFuchsiaSDKArtifacts’ is not required, skipping update. [ ] Artifact Instance of ‘FlutterRunnerSDKArtifacts’ is not required, skipping update. [ +2 ms] Artifact Instance of ‘FlutterRunnerDebugSymbols’ is not required, skipping update. [ +10 ms] Artifact Instance of ‘MaterialFonts’ is not required, skipping update. [ ] Artifact Instance of ‘GradleWrapper’ is not required, skipping update. [ ] Artifact Instance of ‘AndroidMavenArtifacts’ is not required, skipping update. [ ] Artifact Instance of ‘AndroidGenSnapshotArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘AndroidInternalBuildArtifacts’ is not required, skipping update. [ ] Artifact Instance of ‘IOSEngineArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘FlutterWebSdk’ is not required, skipping update. [ ] Artifact Instance of ‘FlutterSdk’ is not required, skipping update. [ ] Artifact Instance of ‘WindowsEngineArtifacts’ is not required, skipping update. [ ] Artifact Instance of ‘MacOSEngineArtifacts’ is not required, skipping update. [ +20 ms] Artifact Instance of ‘LinuxFuchsiaSDKArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘MacOSFuchsiaSDKArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘FlutterRunnerSDKArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘FlutterRunnerDebugSymbols’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ +1 ms] Artifact Instance of ‘FontSubsetArtifacts’ is not required, skipping update. [ +324 ms] Generating /root/parts/color-match/build/android/app/src/main/java/io/flutter/plugins/Gener atedPluginRegistrant.java [ +73 ms] Building Linux application… [ +10 ms] executing: [build/linux/release/] cmake -G Ninja -DCMAKE_BUILD_TYPE=Release /root/parts/color-match/build/linux [ +843 ms] – Configuring done [ +84 ms] – Generating done [ +1 ms] – Build files have been written to: /root/parts/color-match/build/build/linux/release [ +58 ms] executing: ninja -C build/linux/release install [ +7 ms] ninja: Entering directory `build/linux/release’ [+32676 ms] [1/5] Generating /root/parts/color-match/build/linux/flutter/ephemeral/libflutter_linux_gtk.so, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_basic_mes sage_channel.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_binary_co dec.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_binary_me ssenger.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_dart_proj ect.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_engine.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_json_mess age_codec.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_json_meth od_codec.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_message_c odec.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_method_ca ll.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_method_ch annel.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_method_co dec.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_method_re sponse.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_plugin_re gistrar.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_plugin_re gistry.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_standard_ message_codec.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_standard_ method_codec.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_string_co dec.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_value.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/fl_view.h, /root/parts/color-match/build/linux/flutter/ephemeral/flutter_linux/flutter_linu x.h, phony [ +11 ms] Woah! You appear to be trying to run flutter as root. [ ] We strongly recommend running the flutter tool without superuser privileges. [ ] / [ +2 ms]
[ +1 ms] [ +184 ms] executing: [/root/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H [ ] [ +39 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 –pretty=format:%H [ +6 ms] [ ] 61a04b1551a8f63b3081267dc7a0bbc16a1b4bf5 [ ] [ ] executing: [/root/snap/flutter/common/flutter/] git tag –contains HEAD [ ] [ +217 ms] Exit code 0 from: git tag --contains HEAD [ ] [ +2 ms] executing: [/root/snap/flutter/common/flutter/] git describe --match ..-..pre --first-parent --long --tags [ ] [ +15 ms] Exit code 0 from: git describe --match ..-..pre –first-parent --long --tags [ ] [ ] 1.20.0-2.0.pre-193-g61a04b155 [ ] [ +11 ms] executing: [/root/snap/flutter/common/flutter/] git rev-parse --abbrev-ref --symbolic @{u} [ ] [ +5 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u} [ ] [ ] origin/master [ ] [ ] executing: [/root/snap/flutter/common/flutter/] git ls-remote --get-url origin [ ] [ +4 ms] Exit code 0 from: git ls-remote --get-url origin [ +1 ms] [ ] https://github.com/flutter/flutter.git [ +1 ms] [ +58 ms] Unable to locate an Android SDK. [ ] [ +14 ms] executing: [/root/snap/flutter/common/flutter/] git rev-parse --abbrev-ref HEAD [ ] [ +14 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD [ ] [ ] master [ ] [ +59 ms] Artifact Instance of ‘AndroidMavenArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘AndroidGenSnapshotArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘AndroidInternalBuildArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘IOSEngineArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘FlutterWebSdk’ is not required, skipping update. [ +5 ms] [ +3 ms] Artifact Instance of ‘WindowsEngineArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘MacOSEngineArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘LinuxEngineArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘LinuxFuchsiaSDKArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘MacOSFuchsiaSDKArtifacts’ is not required, skipping update. [ +1 ms] [ ] Artifact Instance of ‘FlutterRunnerSDKArtifacts’ is not required, skipping update. [ +1 ms] [ ] Artifact Instance of ‘FlutterRunnerDebugSymbols’ is not required, skipping update. [ ] [ +10 ms] Artifact Instance of ‘MaterialFonts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘GradleWrapper’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘AndroidMavenArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘AndroidGenSnapshotArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘AndroidInternalBuildArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘IOSEngineArtifacts’ is not required, skipping update. [ +1 ms] [ ] Artifact Instance of ‘FlutterWebSdk’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘FlutterSdk’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘WindowsEngineArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘MacOSEngineArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘LinuxEngineArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘LinuxFuchsiaSDKArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘MacOSFuchsiaSDKArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘FlutterRunnerSDKArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘FlutterRunnerDebugSymbols’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ ] [ ] Artifact Instance of ‘IosUsbArtifacts’ is not required, skipping update. [ ] [ +3 ms] Artifact Instance of ‘FontSubsetArtifacts’ is not required, skipping update. [ ] [ +138 ms] Initializing file store [ ] [ +17 ms] Done initializing file store [ ] [ +65 ms] Skipping target: gen_localizations [ ] [+1583 ms] kernel_snapshot: Starting due to {InvalidatedReason.inputChanged} [ ] [ +44 ms] /root/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /root/snap/flutter/common/flutter/bin/cache/artifacts/engine/linux-x64/frontend_ server.dart.snapshot --sdk-root /root/snap/flutter/common/flutter/bin/cache/artifacts/engine/common/flutter_patc hed_sdk_product/ --target=flutter -Ddart.developer.causal_async_stacks=false -Ddart.vm.profile=false -Ddart.vm.product=true –bytecode-options=source-positions --aot --tfa --packages /root/parts/color-match/build/.packages --output-dill /root/parts/color-match/build/.dart_tool/flutter_build/7034b3a7fdd25a8dc2cb4e1cf 16774b3/app.dill --depfile /root/parts/color-match/build/.dart_tool/flutter_build/7034b3a7fdd25a8dc2cb4e1cf 16774b3/kernel_snapshot.d package:color_match/main.dart [ +4 ms] [+2566 ms] unpack_linux: Starting due to {InvalidatedReason.inputChanged} [ ] [ +129 ms] unpack_linux: Complete [ ] [+16782 ms] kernel_snapshot: Complete [ ] [ +330 ms] aot_elf_release: Starting due to {InvalidatedReason.inputChanged} [ ] [ +7 ms] executing: /root/snap/flutter/common/flutter/bin/cache/artifacts/engine/linux-x64-release/g en_snapshot --deterministic --snapshot_kind=app-aot-elf –elf=/root/parts/color-match/build/.dart_tool/flutter_build/7034b3a7fdd25a8dc2c b4e1cf16774b3/app.so --strip --no-causal-async-stacks --lazy-async-stacks /root/parts/color-match/build/.dart_tool/flutter_build/7034b3a7fdd25a8dc2cb4e1cf 16774b3/app.dill [ +1 ms] [+8819 ms] aot_elf_release: Complete [ ] [ +114 ms] Skipping target: linux_aot_bundle [ ] [ +51 ms] release_bundle_linux_assets: Starting due to {InvalidatedReason.inputChanged} [ ] [ +170 ms] release_bundle_linux_assets: Complete [ ] [ +23 ms] Persisting file store [ ] [ +18 ms] Done persisting file store [ ] [ +9 ms] build succeeded. [ ] [ +12 ms] “flutter assemble” took 30,923ms. [ ] [ +143 ms] ensureAnalyticsSent: 135ms [ ] [ +4 ms] Running shutdown hooks [ ] [ ] Shutdown hooks complete [ ] [ +1 ms] exiting with code 0 [+3401 ms] [2/5] Building CXX object CMakeFiles/color_match.dir/flutter/generated_plugin_registrant.cc.o [ +3 ms] [3/5] Building CXX object CMakeFiles/color_match.dir/my_application.cc.o [ +415 ms] [4/5] Linking CXX executable color_match [ ] [4/5] Install the project… [ +13 ms] – Install configuration: “Release” [ +3 ms] – Installing: /root/parts/color-match/build/build/linux/release/bundle/color_match [ ] – Set runtime path of “/root/parts/color-match/build/build/linux/release/bundle/color_match” to “$ORIGIN/lib” [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/icudtl.dat [ +2 ms] – Installing: /root/parts/color-match/build/build/linux/release/bundle/lib/libflutter_linux_gt k.so [ +81 ms] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/Ass etManifest.json [ +1 ms] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/fon ts [ +1 ms] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/fon ts/MaterialIcons-Regular.ttf [ +1 ms] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/ker nel_blob.bin [ +86 ms] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/Fon tManifest.json [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/pac kages [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/pac kages/cupertino_icons [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/pac kages/cupertino_icons/assets [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/pac kages/cupertino_icons/assets/CupertinoIcons.ttf [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/NOT ICES [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/ass ets [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/ass ets/fonts [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/data/flutter_assets/ass ets/fonts/Ubuntu-Medium.ttf [ ] – Installing: /root/parts/color-match/build/build/linux/release/bundle/lib/libapp.so [ +21 ms] Building Linux application… (completed in 37.8s) [ +2 ms] “flutter linux” took 38,353ms. [ +139 ms] ensureAnalyticsSent: 134ms [ +2 ms] Running shutdown hooks [ ] Shutdown hooks complete [ ] exiting with code 0 Skipping build flutter-extension (already ran) Skipping build gnome-3-28-extension (already ran) Cleaning later steps and re-staging color-match (‘build’ step changed) Skipping stage flutter-extension (already ran) Skipping stage gnome-3-28-extension (already ran) Priming color-match Skipping prime flutter-extension (already ran) Skipping prime gnome-3-28-extension (already ran) ‘grade’ property not specified: defaulting to ‘stable’. Snapping |
Snapped color-match_1.0.2_amd64.snap michal@michal-laptop:~/AndroidStudioProjects/color_match$
I’ve got version 4.1.1
Hi. Sorry for digging up this topic but I’m about to publish another Flutter app. I still have this problem and I have no idea how to debug it. Any help much appreciated.
Finally I used “build from GitHub” feature of snapcraft. The resulting file was around 15Mb. And it worked faster than on my laptop
If anyone is interested the app is here: Install Purple Task on Linux | Snap Store