Flutterfire: [firebase_messaging] Registry Conversion Error Between PluginRegistry and FlutterEngine

Created on 29 Dec 2019  Â·  18Comments  Â·  Source: FirebaseExtended/flutterfire

import io.flutter.app.FlutterApplication;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

public class MyApplication extends FlutterApplication implements PluginRegistrantCallback {
    @Override
    public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry registry) {
        GeneratedPluginRegistrant.registerWith(registry); //<--
                }
                }
crowd messaging bug

Most helpful comment

I am also facing this error.
seeing the following message at Debug console

error: incompatible types: PluginRegistry cannot be converted to FlutterEngine
        GeneratedPluginRegistrant.registerWith(registry);

All 18 comments

Hi @pradeep121212
can you please provide your flutter doctor -v ?
Thank you

has this been solved?

Any solutions? Still getting this error

I am also facing this error.
seeing the following message at Debug console

error: incompatible types: PluginRegistry cannot be converted to FlutterEngine
        GeneratedPluginRegistrant.registerWith(registry);

Solution?

@krishnakumarcn Ive try but my app crash

Can you provide the error message?

Do all the steps mentioned in the stack overflow answer.
From changing the conten8of AndroidManifest to creating a new custom plugin registrant.

Unable to instantiate activity ComponentInfo{com.my.pack/com.my.pack.Application}: java.lang.ClassCastException:com.my.pack.Application cannot be cast to android.app.Activity

@krishnakumarcn

The error is:
Unable to instantiate activity ComponentInfo{com.my.pack/com.my.pack.Application}: java.lang.ClassCastException:com.my.pack.Application cannot be cast to android.app.Activity

original Mainactivity

import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {
    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
    }
}

my application.java

import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

public class Application extends FlutterApplication implements PluginRegistrantCallback {

    @Override
    public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry registry) {
        FirebaseCloudMessagingPluginRegistrant.registerWith(registry);
    }
}

@stoppiNeobiz AndroidManifest file?

I'm facing the same issue @krishnakumarcn when I applied the solution from stackoverflow my app is building successfully but not opening. because i have many other plugins used in my app such as firebase Auth, firebase database etc they all got auto registered in GeneratedPluginRegistrant

my configureFlutterEngine is

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)

        flutterEngine.plugins.add(DeviceInfoPlugin())
        flutterEngine.plugins.add(FirebaseAnalyticsPlugin())
        flutterEngine.plugins.add(FirebaseCorePlugin())
        flutterEngine.plugins.add(FirebaseCrashlyticsPlugin())
        flutterEngine.plugins.add(FirebaseRemoteConfigPlugin())
        flutterEngine.plugins.add(FirebaseMessagingPlugin())
        flutterEngine.plugins.add(PackageInfoPlugin())
        flutterEngine.plugins.add(SharedPreferencesPlugin())
        flutterEngine.plugins.add(UrlLauncherPlugin())

        val handler = MethodCallHandler(this)
        MethodChannel(flutterEngine.dartExecutor, MethodCallHandler.CHANNEL_NAME).setMethodCallHandler(handler)
    }

not like yours

    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {

Fatal: failed to find callback problem happnes

Hey all 👋

As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues.

If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.

Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.

Thanks everyone.

Was this page helpful?
0 / 5 - 0 ratings