Android Question Error in console for Firebase

pliroforikos

Active Member
Licensed User
Hello, I'm receiving 3 errors in google console. I think its about firebase messaging and as google say it happens in Android 11 in
samsung a32x and samsung a50 phones.
Please can you explain what happened?
I already updated the app with new instructions about firebase and compiled with 12.20

java.lang.RuntimeException
Exception java.lang.RuntimeException:
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:258)
at anywheresoftware.b4a.BA$1.run (BA.java:360)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8653)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by java.lang.ClassCastException:
at b4a.myClass.b4xpages._getmanager (b4xpages.java:57)
at b4a.myClass.b4xpages._mainpage (b4xpages.java:101)
at b4a.myClass.firebasemessaging._fm_messagearrived (firebasemessaging.java:80)
at java.lang.reflect.Method.invoke
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:221)

java.lang.ClassCastException
Exception java.lang.ClassCastException:
at b4a.myClass.b4xpages._getmanager (b4xpages.java:56)
at b4a.myClass.b4xpages._mainpage (b4xpages.java:100)
at b4a.myClass.firebasemessaging._fm_messagearrived (firebasemessaging.java:160)
at java.lang.reflect.Method.invoke
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:213)
at anywheresoftware.b4a.BA$1.run (BA.java:352)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8595)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)

java.lang.RuntimeException
Exception java.lang.RuntimeException:
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:258)
at anywheresoftware.b4a.BA$1.run (BA.java:360)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8595)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by java.lang.ClassCastException:
at b4a.myClass.b4xpages._getmanager (b4xpages.java:57)
at b4a.myClass.b4xpages._mainpage (b4xpages.java:101)
at b4a.myClass.firebasemessaging._fm_messagearrived (firebasemessaging.java:80)
at java.lang.reflect.Method.invoke
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:221)
 

DonManfred

Expert
Licensed User
Longtime User
I already updated the app with new instructions about firebase and compiled with 12.20
And you replaced firebasemessaging service with the new firebasemessaging receiver?

See updated tutorial:
 
Upvote 0

pliroforikos

Active Member
Licensed User
This is the code in receiver module.
B4X:
Sub Process_Globals
    Public fm As FirebaseMessaging
    Public msgs As Int
End Sub

Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    If FirstTime Then
        fm.Initialize("fm")
        msgs  = 0
    End If
    fm.HandleIntent(StartingIntent)
End Sub

Public Sub SubscribeToTopics
    fm.SubscribeToTopic("myclass")
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    msgs = msgs + 1
    Dim n2 As Notification
    n2.Initialize2(n2.IMPORTANCE_DEFAULT)
    n2.Icon = "icon"
    n2.AutoCancel = True
    n2.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
    n2.Notify(msgs)
    B4XPages.MainPage.showBadge(msgs)
End Sub

Sub fm_TokenRefresh (Token As String)
    Log("TokenRefresh: " & Token)
End Sub
 
Upvote 0
Top