Flutter MissingPluginException与几个插件 [英] Flutter MissingPluginException with several plugins

查看:107
本文介绍了Flutter MissingPluginException与几个插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在使用一些flutter插件.许多工具运行完美,但是我几次遇到令人沮丧的错误,通常导致放弃了插件.

I've been using a handful of flutter plugins recently. Many worked perfectly, but I stumbled across frustrating errors several times, generally resulting in giving up the plugins.

这是我最后得到的, schedule_notifications :

E/flutter (24758): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (24758): MissingPluginException(No implementation found for method getIconResourceId on channel schedule_notifications_app)
E/flutter (24758): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7)
E/flutter (24758): <asynchronous suspension>
E/flutter (24758): #1      _MyAppState._getIconResourceId (<my path>/sandbox/lib/main.dart:67:40)
E/flutter (24758): <asynchronous suspension>
E/flutter (24758): #2      _MyAppState.initState (<my path>/sandbox/lib/main.dart:24:7)
E/flutter (24758): #3      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3751:58)
E/flutter (24758): #4      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3617:5)
E/flutter (24758): #5      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
E/flutter (24758): #6      Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
E/flutter (24758): #7      RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:857:16)
E/flutter (24758): #8      RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:828:5)
E/flutter (24758): #9      RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:774:17)
E/flutter (24758): #10     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2222:19)
E/flutter (24758): #11     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:773:13)
E/flutter (24758): #12     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:662:7)
E/flutter (24758): #13     runApp (package:flutter/src/widgets/binding.dart:704:7)
E/flutter (24758): #14     main (<my path>/sandbox/lib/main.dart:8:16)
E/flutter (24758): #15     _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
E/flutter (24758): #16     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
D/libGLESv2(24758): DTS_GLAPI : DTS is not allowed for Package : <my package>
D/libGLESv1(24758): DTS_GLAPI : DTS is not allowed for Package : <my package>
D/ViewRootImpl(24758): ViewPostImeInputStage processPointer 0
D/ViewRootImpl(24758): ViewPostImeInputStage processPointer 1

在SO和GitHub上有许多类似问题的示例(请参阅我的文章的结尾),但唯一建议解决这些问题的方法是使用flutter cleanflutter upgradeflutter packages get,然后是flutter run". 有时可能就足够了,但并不总是-在我的情况下,我仍然会得到完全相同的错误.

There are many examples of similar questions on SO and GitHub (see the end of my post), but the only thing ever suggested to fix them is "use flutter clean, flutter upgrade, flutter packages get and then flutter run". Sometimes it may be enough, but not always - in my particular case, I still get the exact same error.

值得注意的是,如果我克隆了插件的整个GitHub存储库,并从此目录中运行示例,那么它会很好地工作.但是,如果我尝试重新创建示例项目,则不会,所以我认为我丢失了一些东西,但是呢?

Noticeably, if I clone the whole GitHub repository of the plugin and run the example from within this directory, it does work well. But if I try to re-create the example project, it does not, so I take it I'm missing something, but what ?

以下是我重新创建示例的步骤:

  1. 在Android Studio中创建一个新的Flutter项目

  1. Create a new Flutter project in Android Studio

添加依赖项schedule_notifications: ^0.1.8 in pubspec.yaml

在Android Studio中单击Flutter命令Packages getPackages upgrade

Click on the Flutter commands Packages get and Packages upgrade in Android Studio

在出现的Android Studio中单击弹出窗口Get packages

Click on the popup Get packages in Android Studio when it appeared

https://github粘贴代码.com/serralvo/schedule_notifications/blob/master/example/lib/main.dart 在我的main.dart文件

将行import 'package:schedule_notifications_example/time_picker.dart';更改为import 'time_picker.dart';以解决我从Android Studio获得的错误

Change the line import 'package:schedule_notifications_example/time_picker.dart'; into import 'time_picker.dart'; to resolve the error I got from Android Studio

main.dart旁边创建文件time_picker.dart,并将其中的代码粘贴到

Create a file time_picker.dart next to main.dart and paste in it the code from https://github.com/serralvo/schedule_notifications/blob/master/example/lib/time_picker.dart

在Android Studio中执行项目并获得上述错误

Execute the project in Android Studio and get the aforementioned error

启动Flutter控制台并进入我的项目目录

Launch the Flutter console and go in the directory of my project

在控制台中执行命令flutter cleanflutter upgradeflutter packages get

Execute the commands flutter clean, flutter upgrade, flutter packages get in the console

在控制台中执行命令flutter run,仍然会得到相同的错误

Execute the command flutter run in the console and still get the same error

那么,到底发生了什么?对于某些开发人员或某些项目,某些插件会产生这种行为的原因是什么?我在做什么错了?

类似问题的示例:

Flutter:google_sign_in插件MissingPluginException

在使用Flutter插件时出现MissingPluginException

颤振测试MissingPluginException

Flutter MissingPluginException错误

Flutter:未处理的异常:MissingPluginException(未找到方法的实现频道上的getAll plugins.flutter.io/shared_preferences)

https://github.com/flutter/flutter/issues/10912

推荐答案

就我而言,我已经(错误地)从MainActivity.kt(在onCreate挂钩内)删除了这一行

In my case, I had removed this line(by mistake) from MainActivity.kt (inside the onCreate hook)

    GeneratedPluginRegistrant.registerWith(this)

可能是一个错误,但花了我很多时间.希望可以帮助某人.

Probably a mistake, but cost me a lot of time. Hope helps someone.

这篇关于Flutter MissingPluginException与几个插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆