Android Question (Temp Fix Found) Firebase Messaging Issue with v8.00 SubscribeToTopic

Andrew (Digitwell)

Well-Known Member
Licensed User
Hi
I have upgraded one of my development machines to B4A v8.0

I am now havng problems running an app which uses firebase Messaging

NOTE: this code works fine on another machine running v7.8

TargetSDKVersion is 23 (I'm working my way up to 26 !)

The error I have is :
java.lang.NoSuchMethodError: No virtual method subscribeToTopic(Ljava/lang/String;)V in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging'

Logger connected to: HUAWEI PLK-L01
--------- beginning of main
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
autoversion: 685.0
compilation time: 25 May 2018 14:03:51
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
*** Service (imagedownloader) Create ***
** Service (imagedownloader) Start **
*** Service (phonestatus) Create ***
** Service (phonestatus) Start **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
*** Service (syncgame) Create ***
** Service (syncgame) Start **
** Service (firebasemessaging) Start **
java.lang.NoSuchMethodError: No virtual method subscribeToTopic(Ljava/lang/String;)V in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /mnt/asec/com.cluedupp.cluedupp2-2/base.apk)
at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.SubscribeToTopic(FirebaseNotificationsService.java:130)
at com.cluedupp.cluedupp2.firebasemessaging._subscribetopic(firebasemessaging.java:461)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5546)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
java.lang.RuntimeException: java.lang.NoSuchMethodError: No virtual method subscribeToTopic(Ljava/lang/String;)V in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /mnt/asec/com.cluedupp.cluedupp2-2/base.apk)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:170)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5546)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by: java.lang.NoSuchMethodError: No virtual method subscribeToTopic(Ljava/lang/String;)V in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /mnt/asec/com.cluedupp.cluedupp2-2/base.apk)
at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.SubscribeToTopic(FirebaseNotificationsService.java:130)
at com.cluedupp.cluedupp2.firebasemessaging._subscribetopic(firebasemessaging.java:461)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
... 8 more

The code in Firebase Messaging is:

B4X:
Public Sub SubscribeTopic(topicName As String)
    Private strg As String = MiscCode.ConvertNametoTopic(topicName) ' Replaces invalid characters with underscore
    fm.SubscribeToTopic(strg) ' Error occurs here
    Log("Subscribing to " & strg)
    topics.Add(strg)
End Sub

and I have upgraded the manifest file to use the Macro snippets.

I have also upgraded the FirebaseAnalytics library to 1.01.

Any Ideas?
 

Angel Garcia

Member
Licensed User
Hi,
I just started using B4A 8.3 and i have this same issue when starting the App, already updated the internal library to FirebaseNotifications 1.21 and still same issue.
My App crashes when it starts. It's important to notice that it was fine with B4A 8.0.
java.lang.NoSuchMethodError: No virtual method subscribeToTopic(Ljava/lang/String;)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 blablabla

Am i missing something?
Many thanks in advance!
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Have you updated the Google SDK using the SDK Manager to the latest version?

com.google.firebase:firebase-messaging should be version 17.0.0 or above
 
Upvote 0

Angel Garcia

Member
Licensed User
Great this got worse,
com.google.firebase:firebase-messaging should be version 17.0.0 or above

Just updated as you said and now i got an error of FirebaseAuth:

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.firebase.auth.FirebaseAuth.addAuthStateListener(com.google.firebase.auth.FirebaseAuth$AuthStateListener)' on a null object reference
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
There is another message which deals with this error:
https://www.b4x.com/android/forum/t...te-breaks-firebaseauth-library.93446/#content

Erel said:
The issue with Firebase Auth looks like a bug in the latest version of Firebase Auth SDK (firebase-auth 16.0.1). For now you should use the previous version.

Open B4A Sdk Manager folder and find: extras\b4a_remote\installed-components.txt
Open this file, search for com.google.firebase\:firebase-auth=
Change the version to 15.1.0
 
Upvote 0

Angel Garcia

Member
Licensed User
I'm confused now
I can't find my B4A SDK Manager folder, i was using the old sdkmanager.exe that used the windows interface for updating stuff.
Where is it?


EDIT:
Found it!

Keeps throwing same error, did the correction as Erel said.

I have thi error:
 
Last edited:
Upvote 0

Angel Garcia

Member
Licensed User
I have this:
Can't even reach the first error
 

Attachments

  • Captura.PNG
    Captura.PNG
    9.4 KB · Views: 257
Upvote 0

Angel Garcia

Member
Licensed User
Good news is that i commented the initialization of FirebaseAuth and it seems FirebaseMessaging now works fine.
Still the same issue with FirebaseAuth
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
These issues are not really related to the new B4A version.

firebase-messaging, the Google library, was updated several weeks ago in a binary incompatible way. FirebaseNotifications v1.21 was released to accommodate this change. As this is the latest version it is included with B4A v8.30.

There is an open issue with the latest version of firebase-auth, again the Google library. For now you should use firebase-auth 15.1.0.
 
Upvote 0
Top