Android Question Problem with FirebaseMessaging

pacpinto

Member
Licensed User
Hi,

I'm having trouble getting Firebase notifications working. On iOS I was able to do it without much issues, but on Android I'm at a loss.
I followed the tutorial at https://www.b4x.com/android/forum/t...-messages-firebase-cloud-messaging-fcm.67716/ but when I try to send a notification, my app crashes with these messages written to the log:

B4X:
FirebaseMessaging not found.
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference
    at android.content.ComponentName.<init>(ComponentName.java:132)
    at android.content.Intent.<init>(Intent.java:6510)
    at anywheresoftware.b4a.objects.FirebaseNotificationsService.createIntent(FirebaseNotificationsService.java:68)
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$1.run(FirebaseNotificationsService.java:78)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7405)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)

The app compiles and runs without any issue except when a notification is sent.
Any help would be greatly appreciated.

Thanks!
 

pacpinto

Member
Licensed User
Have you added a service named FirebaseMessaging?
Hi Erel,

Yes I did:

B4X:
Sub Process_Globals
    'Firebase
    Private fm As FirebaseMessaging
End Sub

and then

B4X:
Sub Service_Create
    fm.Initialize("fm")
End Sub

I went through the tutorial several times already, updated the android SDK, and installed the latest version of B4A...

Thank you
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 1
Top