本文介绍了无法将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
发布评论