Dart FFI fails loading dynamic library in MacOS - dart

I am trying to build flutter desktop application in MacOS and trying call C++ code using dart FFI. I have used this GitHub project as template and change some source code to call C++ library. I am able to run this project if I do not use FFI.
https://github.com/google/flutter-desktop-embedding
ERROR :
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following ArgumentError was thrown building MyHomePage(dirty, state: _MyHomePageState#86c2f):
flutter: Invalid argument(s): Failed to load dynamic library (dlopen(/usr/lib/structs.dylib, 1): image not
flutter: found)
flutter:
flutter: The relevant error-causing widget was:
flutter: MyHomePage
flutter: file:///Users/rmazumder/VisualCode-Workspace/flutter-desktop-embedding-master/example/lib/main.dart:39:13
flutter:
flutter: When the exception was thrown, this was the stack:
My Flutter and Dart version:
rmazumder$ flutter --version
Flutter 1.12.15-pre.12 • channel master •
https://github.com/flutter/flutter.git
Framework • revision b2a36ffcd2 (22 hours ago) • 2019-11-26 11:45:51 -0500
Engine • revision e136d637a8
Tools • Dart 2.7.0

Related

error: Build input file cannot be found: '/Users/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')

I'm trying to take the iOS build of a Flutter project. No matter what I try it just gives me the following error:
error: Build input file cannot be found: '/Users/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')
This is the set of commands I am trying to get the build with:
flutter pub get
flutter clean
flutter build ios (this gives the above error)
Here is my flutter doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.16.3-pre.67, on Mac OS X 10.15.3 19D76, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.43.2)
[!] Connected device
! Doctor found issues in 1 category.
The flutter build ios --verbose ends with following error:
Encountered error while building for the device.
#0 throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1 BuildIOSCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:93:7)
<asynchronous suspension>
#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:722:18)
#3 _rootRunUnary (dart:async/zone.dart:1155:38)
#4 _CustomZone.runUnary (dart:async/zone.dart:1048:19)
#5 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#7 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#8 Future._completeWithValue (dart:async/future_impl.dart:526:5)
#9 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:556:7)
#10 _rootRun (dart:async/zone.dart:1147:13)
#11 _CustomZone.run (dart:async/zone.dart:1040:19)
#12 _CustomZone.runGuarded (dart:async/zone.dart:942:7)
#13 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:982:23)
#14 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#15 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#16 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#17 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
Here is the image of the folder structure. As you can see, there is no 'Users' folder that holds the Google plist. So, it is quite confusing why would the script try to copy the plist from a non-existing directory. Any advice to fix this would be highly appreciated. TIA :-)
Remove the GoogleService-Info.plist and then again add the file into the Runner directory using Xcode, then choose copy items if needed and add to target checkmark. I hope this will solve your problem.
Make sure the name of the file is correct, i.e: "GoogleService-info.plist"
Add it to the project in mac finder under the project name and then drag it into the project to reference it.
Finally, go to the file inspector for the plist file and tick the box under target membership to include it as part of the project.
Reference

How to fix "pub get failed(1)"

i wanted to build a Flutter App which is using firestore. I implement Firestore and when i am click on "Packages get" this error came.
The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.
Because kegel_app requires SDK version >=1.19.0 <2.0.0-dev.infinity, version solving failed.
pub get failed (1)
How can i fix this? :/
Pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
cloud_firestore: ^0.2.6
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
kegel_app is a dependency
Because kegel_app requires SDK version >=1.19.0 <2.0.0-dev.infinity"
this tells that this package depends on a very old Flutter version that used Dart 1 or Dart 2 pre-releases.
<2.0.0- (with - after the build number) means only Dart versions that are <2.0.0 or == 2.0.0 but pre-releases.
This package is not compatible with recent Flutter versions and needs to be updated.
kegel_app is your project
Change the SDK version constraint in pubspec.yaml to
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"

Exception whilst trying to display an image in flutter

I am trying to display an image in a flutter app.
I have added an images directory and have a file in that directory called iu.png.
In pubspec.yaml I have:
assets:
- images/iu.png
in main.dart I have:
```
child: new Column(
children: <Widget>[
new Text('Image Demo'),
new Image.asset('images/iu.png'),
],
),
```
When I run the code in either an Android or iOS simulator I get the following exception:
I/flutter ( 9252): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE
╞════════════════════════════════════════════════════ I/flutter (
9252): The following assertion was thrown resolving an image codec:
I/flutter ( 9252): Unable to load asset: images/iu.png I/flutter (
9252): I/flutter ( 9252): When the exception was thrown, this was the
stack: I/flutter ( 9252): #0 PlatformAssetBundle.load
(package:flutter/src/services/asset_bundle.dart:221:7) I/flutter (
9252): I/flutter ( 9252): #1
AssetBundleImageProvider._loadAsync
(package:flutter/src/painting/image_provider.dart:427:44) I/flutter (
9252): I/flutter ( 9252): #2
AssetBundleImageProvider.load
(package:flutter/src/painting/image_provider.dart:412:14) I/flutter (
9252): #3 ImageProvider.resolve.. (package:flutter/src/painting/image_provider.dart:266:86)
I/flutter ( 9252): #4 ImageCache.putIfAbsent
(package:flutter/src/painting/image_cache.dart:143:20) I/flutter (
9252): #5 ImageProvider.resolve.
(package:flutter/src/painting/image_provider.dart:266:63) I/flutter (
9252): (elided 8 frames from package dart:async) I/flutter ( 9252):
I/flutter ( 9252): Image provider: AssetImage(bundle: null, name:
"images/iu.png") I/flutter ( 9252): Image key:
AssetBundleImageKey(bundle: PlatformAssetBundle#54de0(), name:
"images/iu.png", scale: I/flutter ( 9252): 1.0) I/flutter ( 9252):
════════════════════════════════════════════════════════════════════════════════════════════════════
I am using the latest flutter master and flutter doctor output is:
Doctor summary (to see all details, run flutter doctor -v): [✓]
Flutter (Channel master, v0.10.2-pre.21, on Mac OS X 10.13.6 17G65,
locale
en-GB) [✓] Android toolchain - develop for Android devices (Android SDK 28.0.3) [✓] iOS toolchain - develop for iOS devices
(Xcode 10.0) [✓] Android Studio (version 3.2) [✓] IntelliJ IDEA
Community Edition (version 2018.2.3) [✓] Connected device (2
available)
Anyone have any clues?
I had the same problem, but if I put images direcly inside assets folder its working justg fine. In this case you also need to change pubspec.yaml (assets: -ui.png) and then you can load the image with Image.asset('ui.png').
make sure your indentation is done properly in your pubspec.yaml.
Subcategory should be indented two spaces than it's parent category.
PS: The dash counts as the first character in subcategory.
According to flutter docs Adding assets and images indentation should be as following:
flutter:
assets:
- assets/my_icon.png
- assets/background.png
Specify Image path as follows
Image.asset("assets/images/car_android.png")
OR
Image(image: AssetImage("assets/images/car_android.png"))
The problem is flutter can't recognize where your image is exactly stored.
If the problem continues then try to do HOT RESTART this will solve your problem.
Update your pubspec.yaml file before this
If you update pubspec.yaml file then run flutter pub get to update the libraries if your IDE doesn't update it automatically.

Dart Error: error: import of dart:mirrors with --enable-mirrors=false

.yaml file bellow:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
fluttertoast: ^2.0.9
dio: ^1.0.6
json_serializable: ^2.0.0
dev_dependencies:
build_runner: ^1.0.0
json_annotation: ^2.0.0
when I run:
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
Built build/app/outputs/apk/debug/app-debug.apk.
D/OpenGLRenderer( 5350): HWUI GL Pipeline
I/OpenGLRenderer( 5350): Initialized EGL, version 1.4
D/OpenGLRenderer( 5350): Swap behavior 1
D/ ( 5350): HostConnection::get() New Host Connection established
0xa12b3ec0, tid 5379
D/EGL_emulation( 5350): eglCreateContext: 0xa127cf60: maj 2 min 0 rcv 2
D/ ( 5350): SurfaceInterface::setAsyncMode: set async mode 1
D/EGL_emulation( 5350): eglMakeCurrent: 0xa127cf60: ver 2 0 (tinfo
0xa177fe80)
E/flutter ( 5350): [ERROR:flutter/shell/common/shell.cc(188)] Dart Error:
error: import of dart:mirrors with --enable-mirrors=false
E/flutter ( 5350): [ERROR:flutter/shell/common/engine.cc(176)] Could not
prepare to run the isolate.
E/flutter ( 5350): [ERROR:flutter/shell/common/engine.cc(123)] Engine not prepare and launch isolate.
E/flutter ( 5350):
[ERROR:flutter/shell/platform/android/android_shell_holder.cc(167)] Could not launch engine in configuration.
i know the problem is that 'json_serializable' but i didn't know how to resolve it. or is there any way to transform between model and json
I did stumble across your post on my own search after solutions with your problem.
I assume that you want to use json_serializable for your own sourceCode creation.
If this is the case you should have
json_serializable: ^2.0.0
under the dev_dependencies.
Explanation
json_serializable does use dartlang/source_gen internally.
source_gen in turn does reference dart:mirrors, which is not supported in flutter (as told in this post).
So long story in short:
- through removing the dependency on json_serializable from your "build" dependencies you remove the dependency on mirrors which is stopping your flutterBuild.
i know the problem is that 'json_serializable' but i didn't know how to resolve it. or is there any way to transform between model and json
I did not really got that part.
At least for me this is not enough information to provide help on your modelgeneration.
Could try if you post a class in which you use json_serializable and the generated partial class.
I had similar problem. I was using appengine plugin with MethodChannel and once I removed appengine dependency it all worked fine.

flutter reference to unspecified seems stuck at 0.3.4

I'm trying to add a reference to openid_client in my flutter app.
I add a dependency to openid_client: ^0.1.3 in my pubspec.yaml and save. This runs flutter packages get, which reports the following error:
Package unscripted has no versions that match >=0.6.2 <0.7.0 derived from:
- openid_client 0.1.0 depends on version >=0.6.2 <0.7.0
Indeed, the openid_client package does depend on unscripted version 0.6.2, but my flutter app cannot reference 0.6.2. It appears the highest version of unscripted my flutter app can reference is 0.3.4. Does anyone know what I'm doing wrong?
This is my pubspec.yaml as it currently stands:
name: flit
description: A new Flutter project.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.0
english_words: ^3.1.0
openid_client: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true

Resources