我得到MissingPluginException时,试图做的事情在后台



我的大部分后台代码以MissingPluginException结尾,我不知道为什么,但我实现了它所说的一切;我尝试了所有可能的在线解决方案,但都不起作用;现在我面对它与audio_service插件,当我试图从android-home-widget使用播放音频home_widget插件;

最小代码:

AudioPlayerTask audioPlayerTask;
void homeWidgetBackgroundCallback(Uri data) async {
WidgetsFlutterBinding.ensureInitialized();
if(audioPlayerTask == null) {
audioPlayerTask = AudioPlayerTask();
await AudioServiceBackground.run(() => audioPlayerTask);
}
AudioServiceBackground.state.playing ? audioPlayerTask.onPause() : audioPlayerTask.onPlay();
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
HomeWidget.registerBackgroundCallback(homeWidgetBackgroundCallback);
}
<标题>错误信息:
2021-08-12 10:49:25.444 25804-25849/com.******* E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: MissingPluginException(No implementation found for method ready on channel ryanheise.com/audioServiceBackground)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7)
<asynchronous suspension>
#1      AudioServiceBackground.run (package:audio_service/audio_service.dart:1271:24)
<asynchronous suspension>
#2      homeWidgetBackgroundCallback (package:*******/main.dart:72:7)
<asynchronous suspension>
<标题>颤振医生:
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19043.1151], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Ultimate Edition (version 2020.1)
[√] VS Code, 64-bit edition (version 1.58.2)
[√] Connected device (3 available)
• No issues found!

这个错误最多的插件是path_provider插件,它从来没有在后台工作;

有什么建议吗?<标题>

编辑github: https://github.com/ryanheise/audio_service/issues/789

终止正在运行的进程,重新运行应用程序。

这是iOS还是Android?如果是iOS,你必须注册你想要使用的插件,以便能够与HomeWidget plugin进行通信。这是从Home_Widget页面中获取的-对于flutter_workmanager,这是通过添加:

实现的
WorkmanagerPlugin.setPluginRegistrantCallback { registry in
GeneratedPluginRegistrant.register(with: registry)
}

对AppDelegate.swift

相关内容

  • 没有找到相关文章

最新更新