zenon-network / syrius

MIT License
19 stars 14 forks source link

Flutter build fails on Ubuntu #4

Closed AminAzGol closed 1 year ago

AminAzGol commented 2 years ago

After installing flutter successfully and setting up linux environment according to official documentation, still get the following error when I run fluttter build linux

💪 Building with sound null safety 💪

No Linux desktop project configured. See
https://docs.flutter.dev/desktop#add-desktop-support-to-an-existing-flutter
-app to learn about adding Linux support to a project.
AminAzGol commented 2 years ago

had some search and find this solution. it suggests to run flutter create . before flutter build linux

but I got a new error this time:


💪 Building with sound null safety 💪

ERROR: ../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/overlay_support-1.2.1/lib/src/overlay_entry.dart:101:24: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
ERROR:  - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
ERROR:         WidgetsBinding.instance?.scheduleFrameCallback((_) => animateRemove());
ERROR:                        ^
ERROR: ../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/feedback-2.2.1/lib/src/utilities/back_button_interceptor.dart:12:22: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
ERROR:  - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
ERROR:       WidgetsBinding.instance!.addObserver(this);
ERROR:                      ^
ERROR: ../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/feedback-2.2.1/lib/src/utilities/back_button_interceptor.dart:19:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
ERROR:  - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
ERROR:     WidgetsBinding.instance!.removeObserver(this);
ERROR:                    ^
ERROR: ../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/feedback-2.2.1/lib/src/l18n/localization.dart:44:41: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
ERROR:  - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
ERROR:   final Locale? locale = WidgetsBinding.instance?.window.locale;
ERROR:                                         ^
ERROR: ../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/feedback-2.2.1/lib/src/utilities/media_query_from_window.dart:25:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
ERROR:  - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
ERROR:     WidgetsBinding.instance!.addObserver(this);
ERROR:                    ^
ERROR: ../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/feedback-2.2.1/lib/src/utilities/media_query_from_window.dart:70:54: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
ERROR:  - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
ERROR:       data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window),
ERROR:                                                      ^
ERROR: ../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/feedback-2.2.1/lib/src/utilities/media_query_from_window.dart:77:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
ERROR:  - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
ERROR:     WidgetsBinding.instance!.removeObserver(this);
ERROR:                    ^
ERROR: ../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/fl_chart-0.41.0/lib/src/chart/pie_chart/pie_chart.dart:42:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
ERROR:  - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/flutter/packages/flutter/lib/src/widgets/binding.dart').
ERROR:     WidgetsBinding.instance?.addPostFrameCallback((_) {
ERROR:                    ^
Building Linux application...
KingGorrin commented 2 years ago

You need to update the feedback, fl_chart and overlay_support packages, but when doing so will create new errors due to breaking changes in the updated packages.

sol-znn commented 2 years ago

Though it's a bit challenging, I've managed to compile Syrius on Arch and Ubuntu.

As AminAzGol pointed out

had some search and find this solution. it suggests to run flutter create . before flutter build linux

Another point to consider is the directory name for the syrius project. For my first attempt, I downloaded the zipped archive for the master branch, resulting in my Syrius directory being named syrius-master. Due to an issue with flutter create, I had to rename the directory to syrius in order to be Flutter-compliant.

This will allow us to build the project and flutter to execute the code. Also, the WidgetsBinding warnings that follow don't prevent the app from running. Maybe someone else will know how to troubleshoot those but I've found them to be irrelevant.

Instead, after the Syrius splash screen, I see the following message: PlatformException(channel-error, Unable to establish connection on channel., null, null)' syrius-error

This is caused by the Wakelock plugin; due to a lack of Linux support and no operating system distinction in the Syrius code, the Wakelock code is called immediately after the splash screen and causes the error to be displayed.

In order to solve this, I commented out the Wakelock checks in the following files:

After patching those calls, we'll see some unhandled exceptions due to missing files. Example

[ERROR:flutter/runtime/dart_isolate.cc(1098)] Unhandled exception: Zenon SDK Exception: Library libznn could not be found

0 EmbeddedNode.initializeNodeLib (package:zenon_syrius_wallet_flutter/embedded_node/embedded_node.dart:63:7)

1 EmbeddedNode.runNode (package:zenon_syrius_wallet_flutter/embedded_node/embedded_node.dart:85:7)

2 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:300:17)

3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

To solve this, we need to supply some files manually to the Syrius root directory (before or after we run the project, doesn't matter).

Download the Zenon Dart SDK and copy these files to the Syrius root

/lib/src/argon2/blobs/[libargon2_ffi_plugin.so](https://github.com/zenon-network/znn_sdk_dart/blob/master/lib/src/argon2/blobs/libargon2_ffi_plugin.so) -> Syrius root /lib/src/pow/blobs/[libpow_links.so](https://github.com/zenon-network/znn_sdk_dart/blob/master/lib/src/pow/blobs/libpow_links.so) -> Syrius root /lib/embedded_node/blobs/[libznn.so](https://github.com/zenon-network/syrius/blob/master/lib/embedded_node/blobs/libznn.so) -> Syrius root Now, you should be able to compile Syrius on Linux! Hope this helps!
AminAzGol commented 2 years ago

Apparently, the errors I mentioned could be ignored, and the build was completed. I'm not sure this can cause any future problems but for now, I could build and run the app without doing anything about the errors. After the build, at runtime, I encounter the exact problem mentioned by @Sol-Sanctum I followed you're instructions one by one, and the problem was fixed on my next run. image Thank you @Sol-Sanctum for your detailed and easy to follow explanation. I'm looking forward to an official Snap release of Syrius.

0x3639 commented 1 year ago

Install Instructions

git clone -b linux_poc https://github.com/Sol-Sanctum/syrius.git
git clone https://github.com/zenon-network/znn_sdk_dart.git

Download the Zenon Dart SDK and copy these files to the Syrius root

/lib/src/argon2/blobs/libargon2_ffi_plugin.so -> Syrius root /lib/src/pow/blobs/libpow_links.so -> Syrius root /lib/embedded_node/blobs/libznn.so -> Syrius root ``` flutter pub get flutter run ``` Console Error ``` Another exception was thrown: A RenderFlex overflowed by 9.7 pixels on the right. flutter: Info: Empty balance on the selected address ``` ![image](https://user-images.githubusercontent.com/5406130/199624116-bb7f71e0-ef8a-41cb-a11f-03d135b03424.png) ![image](https://user-images.githubusercontent.com/5406130/199624288-ca1be169-2925-4a39-b878-c1540489a2de.png)
sol-znn commented 1 year ago

Syrius v0.0.6 includes the solution I previously described. Anyone should be able to build Syrius from source or use the automatically generated release.

Commit: https://github.com/zenon-network/syrius/commit/c996cc404f721b329d12e9a638a149acd6648bf3

@AminAzGol @zenon-network please close this issue.