"PluginRegistry cannot be converted to FlutterEngine" error in installing firebase_messaging packge on flutter.

10.10.2020 20:17

"PluginRegistry cannot be converted to FlutterEngine" error in installing firebase_messaging packge on flutter.

The solution of the "PluginRegistry cannot be converted to FlutterEngine" error that occurs while installing the firebase_messaging package in Flutter is quite simple. Of course, we understand this after two days of research and finding the problem.

Let's move on to the solution of the problem immediately.

First of all, the following line causes an error.

GeneratedPluginRegistrant.registerWith(registry);

We need to replace the line above with the one below.

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

Then we import the library below.

import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;

Then, using the flutter clean command, you can save the previous build data etc. clean.

If you are still getting errors, you can try updating your flutter and kotlin versions.