Repository navigation
[firebase_messaging] Can't make 5.1.5 to work with instructions. #145
Copy link
Copy link
Closed
Labels
impact: crowdAffects many people, though not necessarily a specific customer with an assigned label. (P2)Affects many people, though not necessarily a specific customer with an assigned label. (P2)plugin: messagingtype: bugSomething isn't workingSomething isn't working
Description
Describe the bug
With 5.1.4 I get the notifications succesfully, but I need the background service in my app. The problem is with 5.1.5 I can't even get the basic notifications.
If the Application.java is not set (it is stated as optional), when I get a notification the app crashes with this error:
java.lang.RuntimeException: Unable to create service io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: java.lang.RuntimeException: PluginRegistrantCallback is not set.
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3577)
at android.app.ActivityThread.access$1400(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1689)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
E/AndroidRuntime(29468): Caused by: java.lang.RuntimeException: PluginRegistrantCallback is not set.
at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:157)
at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.onCreate(FlutterFirebaseMessagingService.java:77)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3565)
When the Application file is set properly along with the onBackgroundMessage, on app startup I get this:
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference, null)
StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
<asynchronous suspension>
FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:118:16)
Messaging.configure (package:vonatles/Network/messaging.dart:51:24)
_AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
Messaging.configure (package:vonatles/Network/messaging.dart:48:25)
main (package:vonatles/main.dart:18:31)
_AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
main (package:vonatles/main.dart:13:10)
_runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:229:25)
_rootRun (dart:async/zone.dart:1124:13)
_CustomZone.run (dart:async/zone.dart:1021:19)
_runZoned (dart:async/zone.dart:1516:10)
runZoned (dart:async/zone.dart:1500:12)
_runMainZoned.<anonymous closure> (dart:ui/hooks.dart:221:5)
_startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:19)
_RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
Flutter doctor:
[√] Flutter (Channel beta, v1.9.1+hotfix.2, on Microsoft Windows [Version 10.0.18362.267], locale hu-HU)
• Flutter version 1.9.1+hotfix.2 at E:\Programs\FlutterSDK\flutter
• Framework revision 2d2a1ffec9 (6 days ago), 2019-09-06 18:39:49 -0700
• Engine revision b863200c37
• Dart version 2.5.0
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\GERGO\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 39.0.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
To Reproduce
Steps to reproduce the behavior:
Following the instructions of firebase_messaging.
Expected behavior
Messaging working properly after following the intstuctions.
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
impact: crowdAffects many people, though not necessarily a specific customer with an assigned label. (P2)Affects many people, though not necessarily a specific customer with an assigned label. (P2)plugin: messagingtype: bugSomething isn't workingSomething isn't working
Activity
Harishpenta commentedon Sep 13, 2019
i was also facing this issue during the implementation by following the documentation. you can follow this link.
and hope it gives you a move further ahead.
https://stackoverflow.com/questions/57851184/unhandled-exception-nosuchmethoderror-the-method-torawhandle-was-called-on-n?noredirect=1#comment102240498_57851184
YonatanAmitzur commentedon Sep 17, 2019
I'm have the "Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' on a null object reference" issue
i made a super empty example and the issue still happening
code:
YonatanAmitzur commentedon Sep 18, 2019
i managed to get to a point where i dont get the error, for some reason when i removed flutter_downloader: ^1.1.7 from pubspec.ymal (update to ^1.1.7 did not helped)
but when i put the app in the background and i am getting a push notification, the onBackgroundMessage handler is not invoke
can some please explain (due to no documentation), when does the onBackgroundMessage handler supposed to be fire ?
banfger commentedon Sep 18, 2019
I've tried to find the issue, and I've created a new project for it, and tried to find the differences, because in the new application everything worked like a charm. What I found is that in my main project I have the 'flutter_typeahead: 1.6.1' plugin, and if I add that to the new project it throws the error and background messages do not work. It adds the keyboard_visibility 0.5.6 plugin too, and in its registerWith() method it throws the getApplication() on a null object error.
As I see YonatanAmitzur's flutter_downloader problem is the same, because in its registerWith() method it tries to get the application too.
If I don't set up the flutter_messaging, the flutter_typeahead plugin works without errors. Should I move there with the issue, or stay here?
cetorres commentedon Sep 20, 2019
Hi, I could configure well to the point that I can receive push notification with the app terminated (after it runs at least once). The notifications arrive, but when we click on them and it opens the app, it doesn't get the notification payload, doesn't trigger any of the configure methods.
markuspaschi commentedon Sep 21, 2019
@cetorres if you receive all messages properly, but the onResume / onLaunch ist not triggered, then you forgot the "click_action" payload in your notification (not possible through firebase console) or didnt specifiy it in your manifest. Check readme.md for the exact implementation :)
cetorres commentedon Sep 21, 2019
@markuspaschi I'm sending the "click_action" inside the data in my payload. And I also have it configured correctly in my Android manifest.
I'm receiving the notification in the Android tray system when the app is terminated. Only when I tap on it and the app opens that nothing happens. It was supposed to send the notification payload to a stream I have configured that's being listened on the main screen to show a dialogbox with the data from the notification. It works normally if the app is in foreground or in background, but not terminated.
Please see below:
My payload that's being sent to https://fcm.googleapis.com/fcm/send
{ "notification": { "title": "New Customer", "body": "A new customer was created." }, "priority": "high", "data": { "click_action": "FLUTTER_NOTIFICATION_CLICK", "customer_id": 1, "customer_name": "Test Customer", "user_name": "John Doe", "user_id": 2 }, "to": "[DEVICE_ID]" }Inside my AndroidManifest.xml
brunoripa commentedon Sep 22, 2019
I have changed NOTHING . in my code and suddenly this error appeared, still haven't fixed :/
badf007 commentedon Sep 23, 2019
I'm using Flutter and I'm looking at the "[ZeroHung]zrhung_get_config: Get config failed for wp[0x0008]" that is network related error connected to Honor and Huawei devices, I want to know if the people here having issues with network connectivity, using HTPP package or using other network-related packages ( like firebase) have Honor or Huawei devices too. I have identified 2 models that have this issues ID: COR L29 that's an Honor Play phone and ID: SNE LX3 is a Huawei Mate 20. Thanks and sorry to bother.
ektelat commentedon Sep 29, 2019
all the time my app is terminated an on debug console writen:
D/AndroidRuntime( 2912): Shutting down VM
E/AndroidRuntime( 2912): FATAL EXCEPTION: main
E/AndroidRuntime( 2912): Process: com.thioffices.thioffices, PID: 2912
E/AndroidRuntime( 2912): java.lang.RuntimeException: Unable to create service io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: java.lang.RuntimeException: PluginRegistrantCallback is not set.
my firebase_messaging: firebase_messaging: ^5.1.6
banfger commentedon Sep 29, 2019
Did you write your onBackgroundMessage handler as a global function? If not, you might get this PluginRegistranrCallback error.
charleshan commentedon Oct 16, 2019
I'm also having this issue. Yes, I have
onBackgroundMessageas a global function.sm-tester commentedon Oct 20, 2019
I have same error 5.1.6 version. If you add onBackgroundMessage callback will be another error:
Conclusion: Firebase Messaging full not works on Flutter, because not variant to use it.
iapicca commentedon Oct 24, 2019
Hi @banfger
I see there's an open issue addressing the case you described.
Please follow up on that issue,
I'm closing the current one as duplicate.
If you disagree please write in the comments
and I will reopen it.
Thank you
wmattei commentedon Nov 5, 2019
@iapicca it's not the same problem, This error is due to a bug that does not allow you to register plugins when using a custom Main in AndroidManifest.xml. Even though the class inherits from FlutterApplication, currentActivity is always null causing NullPointerException when trying to register a plugin.
michelebombardi commentedon Nov 20, 2019
Same @banfger issue problem (the first post) with version
5.1.8. This issue is still present.Why it has been closed?
tharit-haup commentedon Jan 3, 2020
In my case it conflict with flutter_blue. The same as you. Any solution or work-around for this problem.
AxesandGrinds commentedon Feb 13, 2020
For DomingoMG's answer here
https://stackoverflow.com/questions/59446933/pluginregistry-cannot-be-converted-to-flutterengine/60211138#60211138
and
don't forget to remove
@Override public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine);from the mainactivity file under the android folder. If not, you will get an error.
xxxNGBxxx commentedon Mar 2, 2020
I have the same conflict with flutter_blue. Maybe you found solution to fix it?
xxxNGBxxx commentedon Mar 3, 2020
This helped in my project:
in Application.kt
Salakar commentedon Nov 4, 2020
Hey all 👋
As part of our roadmap (#2582) we've just shipped a complete rework of the
firebase_messagingplugin 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 🤓