Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_messaging] Registry Conversion Error Between PluginRegistry and FlutterEngine #1729

Closed
pradeep121212 opened this issue Dec 29, 2019 · 18 comments
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: messaging type: bug Something isn't working

Comments

@pradeep121212
Copy link

pradeep121212 commented Dec 29, 2019

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); //<--
                }
                }
@iapicca
Copy link

iapicca commented Dec 31, 2019

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

@iapicca iapicca added type: bug Something isn't working impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) labels Dec 31, 2019
@Sijankhadk65
Copy link

has this been solved?

@krishnakumarcn
Copy link

Any solutions? Still getting this error

@pradeep121212
Copy link
Author

pradeep121212 commented Jan 23, 2020 via email

@iampopal
Copy link

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);

@stoppiNeobiz
Copy link

Solution?

@krishnakumarcn
Copy link

@stoppiNeobiz
Copy link

@krishnakumarcn Ive try but my app crash

@krishnakumarcn
Copy link

Can you provide the error message?

@krishnakumarcn
Copy link

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

@stoppiNeobiz
Copy link

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

@stoppiNeobiz
Copy link

@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);
    }
}

@krishnakumarcn
Copy link

@stoppiNeobiz AndroidManifest file?

@gakubhat
Copy link

gakubhat commented Jan 29, 2020

Refer to this comment

@Nagarajnaidu921
Copy link

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

@kirstywilliams kirstywilliams changed the title flutter firebase messaging Background Service:"GeneratedPluginRegistrant.registerWith(registry); " this line shows error saying registry should be of type FlutterEngine but is of type PluginRegistry [firebase_messaging] Error with incorrect plugin registry type: Background Service:"GeneratedPluginRegistrant.registerWith(registry); " Apr 20, 2020
@kirstywilliams kirstywilliams changed the title [firebase_messaging] Error with incorrect plugin registry type: Background Service:"GeneratedPluginRegistrant.registerWith(registry); " [firebase_messaging] Registry Conversion Error Between PluginRegistry and FlutterEngine Apr 20, 2020
@yourshinsuke
Copy link

yourshinsuke commented Aug 17, 2020

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) {

@yourshinsuke
Copy link

Fatal: failed to find callback
``` problem happnes

Ehesp pushed a commit that referenced this issue Oct 20, 2020
* Fix build failures due to CocoaPods version
* Fix ml_vision Podfile
* Reformat
* Update pubspec.yaml and CHANGELOG
@Salakar
Copy link
Member

Salakar commented Nov 5, 2020

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.

@Salakar Salakar closed this as completed Nov 5, 2020
@firebase firebase locked and limited conversation to collaborators Dec 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: messaging type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests