Android Question App update and firebase issue with "new" Receiver method

QtechLab

Active Member
Licensed User
Longtime User
Hello there,

Today i download the new version of B4A in order to properly update an app developed a few years ago.
I read firebase implementation changes about Service and Receiver, so i've added the Receiver to my code and deleted old FirebaseMessaging Service.

Do i miss some step?

Now this happens when i call the subscribe function and is the first time.

just to know, the new b4a installation is under x64 applications folder and the old one is under x86



Thanks in advance for your time,
Best regards

Log:
*** Receiver (firebasemessaging) Receive (first time) ***
java.lang.NoSuchMethodError: No virtual method getToken()Lcom/google/android/gms/tasks/Task; in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /data/app/~~HQ4jBGzvlLYzUxhwKkDVKg==/com.MeService.MeServiceOffice-rZzsfzfHIlbUooGtHtmLgA==/base.apk)
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.updateToken(FirebaseNotificationsService.java:117)
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.Initialize(FirebaseNotificationsService.java:114)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.MeService.MeServiceOffice.firebasemessaging.onReceive(firebasemessaging.java:42)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4449)
    at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2256)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.app.ActivityThread.main(ActivityThread.java:8177)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
java.lang.RuntimeException: Unable to start receiver com.MeService.MeServiceOffice.firebasemessaging: java.lang.RuntimeException: java.lang.NoSuchMethodError: No virtual method getToken()Lcom/google/android/gms/tasks/Task; in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /data/app/~~HQ4jBGzvlLYzUxhwKkDVKg==/com.MeService.MeServiceOffice-rZzsfzfHIlbUooGtHtmLgA==/base.apk)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4458)
    at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2256)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.app.ActivityThread.main(ActivityThread.java:8177)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: No virtual method getToken()Lcom/google/android/gms/tasks/Task; in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /data/app/~~HQ4jBGzvlLYzUxhwKkDVKg==/com.MeService.MeServiceOffice-rZzsfzfHIlbUooGtHtmLgA==/base.apk)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:188)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.MeService.MeServiceOffice.firebasemessaging.onReceive(firebasemessaging.java:42)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4449)
    ... 9 more
Caused by: java.lang.NoSuchMethodError: No virtual method getToken()Lcom/google/android/gms/tasks/Task; in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /data/app/~~HQ4jBGzvlLYzUxhwKkDVKg==/com.MeService.MeServiceOffice-rZzsfzfHIlbUooGtHtmLgA==/base.apk)
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.updateToken(FirebaseNotificationsService.java:117)
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.Initialize(FirebaseNotificationsService.java:114)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    ... 12 more
FirebaseMessaging:
Sub Process_Globals
    Private fm As FirebaseMessaging
End Sub

'Called when an intent is received.
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    If FirstTime Then
        fm.Initialize("fm") 'Crash happens here'
    End If
    fm.HandleIntent(StartingIntent)
End Sub


Public Sub SubscribeToTopics(topic As String)
    fm.SubscribeToTopic(topic) 'you can subscribe to more topics
End Sub

public Sub UnsubscribeFromTopics(topic As String)
    fm.UnsubscribeFromTopic(topic)
End Sub


Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    
    Dim n As NB6
    n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(LoadBitmap(File.DirAssets, "Notification.png"))
    n.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), DateTime.Now, Me).Notify(DateTime.Now) 'It will be Main (or any other activity) instead of Me if called from a service.
        
End Sub
 

asales

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What @asales is telling you is that you MUST install a NEW SDK based on the Installationinstructions.
The SDK has changed some time ago and the old sdk you installed years ago isn´t compatible any longer.
 
Upvote 0

QtechLab

Active Member
Licensed User
Longtime User
What @asales is telling you is that you MUST install a NEW SDK based on the Installationinstructions.
The SDK has changed some time ago and the old sdk you installed years ago isn´t compatible any longer.
Done it. Updated the both java and android things.
I was using 2y old sdk and java 11. Now everything works like a charm.
 
Upvote 0
Top