-
Notifications
You must be signed in to change notification settings - Fork 4k
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] PluginRegistrantCallback is not set on Android #2077
Comments
exact same issue. the error appears when using background notification.
```
`E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): Failed to handle method call
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): java.lang.RuntimeException: PluginRegistrantCallback is not set.
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:157)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.onMethodCall(FirebaseMessagingPlugin.java:176)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.flutter.io/firebase_messaging(12720): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/mattuvandi.use(12720): Background concurrent copying GC freed 18711(1011KB) AllocSpace objects, 12(304KB) LOS objects, 50% free, 2MB/4MB, paused 11.526ms total 155.904ms E/flutter (12720): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, PluginRegistrantCallback is not set., null)
|
same issue, is there any solution yet? |
Application.java replace:public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
@Override
public void registerWith(PluginRegistry registry) {
GeneratedPluginRegistrant.registerWith(registry);
}
} Application.java with: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 io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
@CallSuper
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
@Override
public void registerWith(PluginRegistry pluginRegistry) {
FirebaseMessagingPlugin.registerWith(pluginRegistry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
} |
I run in to error while using @callsuper. As per android document it is deprecated. manifest.xml:
`
Mainactivity.Java
`
Application.java
````
package com.mattuvandi.user;
import android.os.Bundle;
import io.flutter.app.FlutterApplication;
import io.flutter.app.FlutterActivity;
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 io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
public class Application extends FlutterApplication implements PluginRegistrantCallback { @OverRide Error:
````E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): Failed to handle method call
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): java.lang.RuntimeException: PluginRegistrantCallback is not set.
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:157)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.onMethodCall(FirebaseMessagingPlugin.java:176)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.flutter.io/firebase_messaging(14771): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/flutter (14771): Login Status true
I/mattuvandi.use(14771): Background concurrent copying GC freed 12428(1431KB) AllocSpace objects, 23(684KB) LOS objects, 49% free, 2024KB/3MB, paused 1.106ms total 237.579ms
E/flutter (14771): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, PluginRegistrantCallback is not set., null)
E/flutter (14771): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (14771): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter (14771):
E/flutter (14771): #2 FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:130:16)
E/flutter (14771): #3 firebaseNotification (package:Mattuvandi/app_screens/home/Home.dart:432:27)
E/flutter (14771): #4 _HomeState.build (package:Mattuvandi/app_screens/home/Home.dart:48:7)
E/flutter (14771): #5 StatefulElement.build (package:flutter/src/widgets/framework.dart:4334:27)
E/flutter (14771): #6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4223:15)
E/flutter (14771): #7 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (14771): #8 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter (14771): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter (14771): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter (14771): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (14771): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (14771): #13 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (14771): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (14771): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (14771): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (14771): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (14771): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter (14771): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter (14771): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (14771): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (14771): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (14771): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (14771): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (14771): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (14771): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (14771): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (14771): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (14771): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (14771): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter (14771): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter (14771): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter (14771): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (14771): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (14771): #35 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (14771): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (14771): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (14771): #38 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (14771): #39 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (14771): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (14771): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (14771): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (14771): #43 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter (14771): #44 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
````
|
@ClevercodeTech @h0x539 Could you maybe wrap your code into a |
thanks for the suggestion. Updated as per your suggestion. |
Try to make a standalone build of the android module. Android Studio -> right click on android package -> Flutter -> Open Android module in Android Studio Flutter Android module in Android Studio -> Terminal -> |
Resolved the issue. Flutter instruction was not clear or i didn't get what they were saying.
to
<application |
I did it and the error is out, but it is not calling the onBackgroundMessage anymore. |
Closing this issue because it looks like it's resolved. @kalibu if you are still experiencing issues calling the onBackgroundMessage with the latest version of Flutter and FlutterFire plugin, can you please provide your updated |
This has not been resolved at all. |
@creativecreatorormaybenot did you try the solution provided by @ClevercodeTech ? |
@helenaford That "solution" only makes the error message go away and does not fix the underlying problem (the plugin is broken on Android, see #2017 for a start; there are way more issues for background messages). The plugin would at least need to address this somewhere. Even if the underlying problem is not fixed immediately, the |
Background message works for me. you need to add a static method to capture the incoming message from firebase server. Below is a sample code
below is the detailed code
|
If that works with all versions (Flutter beta + master too), then I suppose that would be a solution. |
@ClevercodeTech Can you provide detailed instructions? |
Please follow the instruction as shown in the following link for receiving background message. usually flutter application starts like this
you need to change the name to below
.Application refers to Application.java. Which contains below. package com.domain.application
|
Doesn't work for me. Tried to switch branch from |
could you please post your code. |
Sure. // Application.kt
class Application : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this);
// ...
}
override fun registerWith(registry: PluginRegistry?) {
FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
// ...
}
} // AndroidManifest.xml
<application
android:name=".Application" // Changed from `io.flutter.app.FlutterApplication`
... /> // build.gradle under app
// ...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-messaging:20.1.6'
// ...
} |
have you included
|
Yes. // under [project]/android/build.gradle
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
} // under [project]/android/app/build.gradle
// ...
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" |
Not sure if this helps. But i added activity tag as below in manifest.
|
@ClevercodeTech, thanks, unfortunately I have pretty similar config. |
Unable to create service io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: java.lang.RuntimeException: PluginRegistrantCallback is not set. |
how to fix? |
have the same issue on android only, setting Background Message resolves the issue |
This one worked for me |
My app crashes when app is in the background or not running and receives notification. The official flutter migration guide (https://firebase.flutter.dev/docs/migration/) is saying the following. Ensure that you're not manually importing any Firebase Android SDK dependencies in your android/app/build.gradle files dependencies { ... } section.e.g. remove any lines similar to: implementation 'com.google.firebase:firebase-{PRODUCT}:{VERSION} But the solution says that we need to add the com.google.firebase:firebase-messaging to the gradle file. |
How did you resolved? now using new flutter dependency : firebase_messaging: "^8.0.0-dev.6" |
@xlcod I followed the migration guide and on dart code I have:
|
I also get confused by this. The readme on pub.dev is totally different with one on FlutterFire's migration guide. |
Using the new version I am getting these errors: Running Gradle task 'assembleDebug'...
Application.kt: (5, 27): Unresolved reference: firebasemessaging
Application.kt: (6, 27): Unresolved reference: firebasemessaging
Application.kt: (11, 9): Unresolved reference: FlutterFirebaseMessagingService
Application.kt: (15, 9): Unresolved reference: FirebaseMessagingPlugin |
Solution ! <application |
Same problem Solution : |
Same here |
You have to delete platform initialization, in the new version you don't need to add any code in android platform. |
and then in strings.xml, I add 9c81f06, but I'm still getting errors. Here is the error I'm getting. |
if I take out the notification channels setup stuff, I get this error |
change your imports to |
That's what worked for me
dont forget to change your AndroridManifest.xml
if you receiving a blank body/title message you may try this workaround here |
Where should I create the Application.java file? Same directory as |
@Darksoulsong, right near the |
@lexdevel - This worked for me! I am not sure if the notifications are loading yet but at least I got around to building a working APK! Thanks again! |
Hey @creativecreatorormaybenot, are you still experiencing the same problem using the latest messaging version: |
still same error with latest version of the fcm package firebase_messaging 10.0.0 |
After A lot of searching . The problem is from this import this is Kotlin Applictaion class replace it with yours (credits to Obadajasm)
|
// In your Application.java, Try this, it works for me import io.flutter.app.FlutterApplication; public class Application extends FlutterApplication implements PluginRegistrantCallback { @OverRide // In your manifeste make sure to change android:name="io.flutter.app.FlutterApplication" to android:name=".Application" // from official manual : https://firebase.flutter.dev/docs/messaging/overview/ |
I don't see this line in my android manifest ( android:name="io.flutter.app.FlutterApplication" to android:name=".Application" ) |
Closing this issue as it is no longer a problem on the latest firebase_messaging plugin & flutter versions. |
This is caused by:
This happens on Android when running a Flutter app built with
firebase_messaging: 6.0.9
andFlutter 1.15.4-pre.199
.This also happens every time calling
FirebaseMessaging.configure
in the Flutter app when running on Android:The text was updated successfully, but these errors were encountered: