无法将PluginRegistry转换为FlutterEngine

编程入门 行业动态 更新时间:2024-10-27 20:35:58
本文介绍了无法将PluginRegistry转换为FlutterEngine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

将Flutter更新至1.12.13版后,我发现了此问题,无法解决.我按照发送的firebase_messaging教程进行操作时收到以下错误: 错误:类型不兼容:PluginRegistry无法转换为FlutterEngine GeneratedPluginRegistrant.registerWith(注册表); " 我的代码如下:

As soon as I updated the flutter to version 1.12.13 I found this issue and can't fix it. I did as the firebase_messaging tutorial sent and got the following error: "error: incompatible types: PluginRegistry cannot be converted to FlutterEngine GeneratedPluginRegistrant.registerWith (registry); " My code is as follows:

package io.flutter.plugins; import io.flutter.app.FlutterApplication; import io.flutter.pluginmon.PluginRegistry; import io.flutter.pluginmon.PluginRegistry.PluginRegistrantCallback; import io.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService; import android.app.NotificationChannel; import android.app.NotificationManager; import android.os.Build; public class Application extends FlutterApplication implements PluginRegistrantCallback { @Override public void onCreate() { super.onCreate(); FlutterFirebaseMessagingService.setPluginRegistrant(this); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ NotificationChannel channel = new NotificationChannel("messages","Messages", NotificationManager.IMPORTANCE_LOW); NotificationManager manager = getSystemService(NotificationManager.class); manager.createNotificationChannel(channel); } } @Override public void registerWith(PluginRegistry registry) { GeneratedPluginRegistrant.registerWith(registry); } }

推荐答案

替换此代码行:

GeneratedPluginRegistrant.registerWith(registry);

与此:

FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));

请确保导入:

import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;

更多推荐

无法将PluginRegistry转换为FlutterEngine

本文发布于:2023-11-10 02:54:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574148.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   PluginRegistry   FlutterEngine

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!