Android Question FirebaseMessaging in B4A 8.30

Semen Matusovskiy

Well-Known Member
Licensed User
Hi, guys --

I get java.lang.NoSuchMethodError: com.google.firebase.messaging.FirebaseMessaging.subscribeToTopic in new release.
I updated absolutelly all - Java 64-bit, Android Studio (all SDK platforms and tools are installed), SDK Manager in B4A.
Nothing helps. Meanwhile FirebaseMessaging.jar from 8.0 works fine.
What is interesting, java code in both jar files is 100% the same.

Any ideas ?
 

tucano2000

Active Member
Licensed User
Longtime User
I had the same problem. I had tried to update the firebasemessaging and analitcs library that way but it did not work.

https://www.b4x.com/android/forum/threads/updates-to-internal-libraries.59340/#post-591400

So while reading this tutorial from the shortcut below.

https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/#content

I managed to solve it by adding this in the manifest editor.

B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

My project worked before without adding to the Manifest Editor in B4A 7.0. It is now required in B4A 8.0+

I hope it's useful

Edit: I also had to add the code below in #Region Project Attributes

B4X:
#AdditionalJar: com.google.android.gms:play-services-base

I change Manifest Editor to uses sdk 26

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="26"/>
 
Last edited:
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Thanx for reply.

I made simple sample. To run it, it's necessary to change project name and to copy google-services.json
Error in 8.30, but works fine, if to copy FilebaseMessaging.jar from B4A 8.00
 

Attachments

  • 1.zip
    8.8 KB · Views: 298
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User
Your project is working perfectly here. I tested it on B4A 8.30.

Did you upgrade Firebase Notifications as shown here?

https://www.b4x.com/android/forum/threads/updates-to-internal-libraries.59340/#post-586377

Previously I also updated Analytics because my project uses it. I downloaded the libraries and replaced the libraries in the B4A libraries folder.

You have changed your Android SDK to Android SDK Command Line Tools as shown in steps 2 and 3?

https://www.b4x.com/b4a.html

Changed the path shown in this process by updating your SDK from the B4A menu for the new SDK?

I have read in some forums that one should not test in the Android Emulator. I also read that your device must have an updated version of Google Play Services.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I get java.lang.NoSuchMethodError: com.google.firebase.messaging.FirebaseMessaging.subscribeToTopic in new release.
I updated absolutelly all - Java 64-bit, Android Studio (all SDK platforms and tools are installed), SDK Manager in B4A.
Nothing helps. Meanwhile FirebaseMessaging.jar from 8.0 works fine.
What is interesting, java code in both jar files is 100% the same.
Make sure that all recommended items are up to date in B4A Sdk Manager. Based on the partially posted error message you are using an old version of firebase-messaging resource.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
I don't understand, how "an old version of firebase-messaging resource" appears.
I completely uninstall Java, Android Studio, SDK Tools, B4A. Then manully searched corressponding folders and removed them.
And after this only I install all again. Distributives are current (I download from Web-site).

Of course, this is no garantee that I found all. What to check in registry / folders ?

Complete log:

B4X:
firebasemessaging_subscribetotopics (java line: 148)
java.lang.NoSuchMethodError: com.google.firebase.messaging.FirebaseMessaging.subscribeToTopic
    at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.SubscribeToTopic(FirebaseNotificationsService.java:130)
    at com.quick.men.firebasemessaging._subscribetotopics(firebasemessaging.java:148)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
    at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1154)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:157)
    at android.app.ActivityThread.main(ActivityThread.java:5356)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
    at dalvik.system.NativeStart.main(Native Method)
 
Last edited:
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Erel --

Due to your remark "You don't need Android Studio at all" I understood a reason of troubles.

I set "android.jar" path according comment "usually found under C:\Android-sdk\platforms\android-x". Like I understand, B4a refers to SDK folder in Android Studio.
By unknown reasons Android Studio installs firebase-messaging mavens from 9.0.0 to 11.0.4 only. Release 17.0.0 is not present.

So, I changed android.jar path to B4A SDK Manager folder.
Now works. Thanx
 
Upvote 0
Top