Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PluginRegistry cannot be converted to FlutterEngine

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.plugin.common.PluginRegistry; import io.flutter.plugin.common.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);   } } 
like image 464
Gabriel G. Pavan Avatar asked Dec 22 '19 18:12

Gabriel G. Pavan


1 Answers

Replace this code line:

GeneratedPluginRegistrant.registerWith(registry); 

with this:

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

Make sure to import:

import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin; 
like image 149
mehrdad seyrafi Avatar answered Sep 19 '22 20:09

mehrdad seyrafi