yekeskin / flutter_avif

A flutter plugin to view and encode avif images.
https://pub.dev/packages/flutter_avif
MIT License
47 stars 15 forks source link

flutter throw a exception:Field 'api' has not been initialized #24

Closed fuwuyuan closed 1 year ago

fuwuyuan commented 1 year ago

Hi,i am back again,i found a new exception.

flutter_avif_ios` threw an error: Invalid argument(s): Failed to lookup symbol 'store_dart_post_cobject': dlsym(RTLD_DEFAULT, store_dart_post_cobject): symbol not found. The app may not function as expected until you remove this plugin from pubspec.yaml'

First one is the old i have submited,and the next is the new when i use AvifImage.network(imageUrl,fit: fit,)

flutter: ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════ flutter: The following _Exception was thrown resolving an image frame: flutter: Exception: LateInitializationError: Field 'api' has not been initialized. flutter: flutter: When the exception was thrown, this was the stack: flutter: #0 SingleFrameAvifCodec.getNextFrame (package:flutter_avif/src/avif_image.dart:833:7) flutter: #1 AvifImageStreamCompleter._decodeNextFrameAndSchedule (package:flutter_avif/src/avif_image.dart:968:34) flutter: #2 AvifImageStreamCompleter._handleCodecReady (package:flutter_avif/src/avif_image.dart:927:7) flutter: flutter: (elided 2 frames from dart:async) flutter: flutter: Url: flutter: https://static.clzg.cn/upload/clzg/2020/09/14/16000170096875847870994355657_186800.jpg?x-oss-process=style/clzg_content_avif&clzg_scale=2080,4624

I know i take a long time,but i cannot solve it,i had tried every solution i can find,i am so sorry,could you please take a look

yekeskin commented 1 year ago

Can you also share your flutter and dart sdk versions? I am using dartPluginClass' registerWith method to initialize the api field and it was added in flutter 2.5.

fuwuyuan commented 1 year ago

This is my flutter version

Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git Framework • revision f468f3366c (4 weeks ago) • 2023-07-12 15:19:05 -0700 Engine • revision cdbeda788a Tools • Dart 3.0.6 • DevTools 2.23.1

fuwuyuan commented 1 year ago

Can you also share your flutter and dart sdk versions? I am using dartPluginClass' registerWith method to initialize the api field and it was added in flutter 2.5.

Yes,i have readed your code,i found it. The store_dart_post_cobject exception from ffi or flutter_rust_bridge,something wrong here where i were not found.Something i had tried,like https://docs.flutter.dev/platform-integration/ios/c-interop and https://lifelonglearni.ng/ios-failed-to-lookup-symbol these doesn't work for me.

yekeskin commented 1 year ago

Your flutter version shouldn't be an issue. So if the registerWith method is getting called but you got these errors, I think for some reason flutter_avif binaries are not getting bundled with your build. Can you make sure you have ios/.symlinks/plugins/flutter_avif_ios/ios/Frameoworks/FlutterAvif.xcframework folder in your project? Also please check that you have flutter_avif_ios under the Pods list in Xcode.

Screenshot 2023-08-08 at 13 39 49 Screenshot 2023-08-08 at 13 43 29

You mentioned in your previous post that the plugin works fine on a new project. Do you get the Field 'api' has not been initialized exception also on a new project?

And lastly, I would really appreciate if you can share a way or repo to reproduce the error. I cannot do much without reproducing the error on my device.

fuwuyuan commented 1 year ago

Something wrong maybe i make sure,if you create a new projecr with object-c language not swift.The exception will reproduce.it is work on a project that with swift. avif my project is an oc object.The picture shows create a project in android studio,i doesnt find the similar page in vscode,and i am try to push the new project for you https://github.com/fuwuyuan/avif_test.git

yekeskin commented 1 year ago

Thanks, I was able to reproduce the issue. I fixed it by following the suggestion here and adding use_frameworks! to the Podfile in the ios directory of your project.

fuwuyuan commented 1 year ago

Thanks, I was able to reproduce the issue. I fixed it by following the suggestion here and adding use_frameworks! to the Podfile in the ios directory of your project.

Nice work,its worked,thanks very much,thank you again.