Java Question Firebase java Server jar


Licensed User
Based on
i found this code to implement.

// Initialize the app with a service account, granting admin privileges
FirebaseOptions options = new FirebaseOptions.Builder()
    .setServiceAccount(new FileInputStream("path/to/serviceAccountCredentials.json"))

// As an admin, the app has access to read and write all data, regardless of Security Rules
DatabaseReference ref = FirebaseDatabase
ref.addListenerForSingleValueEvent(new ValueEventListener() {
    public void onDataChange(DataSnapshot dataSnapshot) {
        Object document = dataSnapshot.getValue();
In my eclipse-project i referenced the jar

And the code does not raise a problem inside Eclipse... The methods are not marked "as bad"

BUT if i then want to compile the library with SLC i get the following error.

The file firebase-server-sdk-3.0.1.jar does exists inside the libs folder of the project and also it is available in the B4J Additional libs folder.

Why SLC (or java?) is not able to resolve the reference?


Staff member
Licensed User
There are duplicate classes in firebase-common.jar and firebase-server-sdk-3.0.1.jar. The builder in firebase-common.jar doesn't include the relevant methods. I think that you don't need firebase-common.jar at all.

Note that if a class has instance variables then it shouldn't be an AbsObjectWrapper class. The wrapper will be lost and recreated in several scenarios.

For example:
Dim fd As FirebaseDatabase = list1.Get(0) 'a new wrapper is created. Instance variables will be lost.


Licensed User
Instance variables will be lost.
How can i prevent instance-variables to get lost then?

It also happens in the B4A Firebase-Realtime databasewrapper when you get a reference from a reference. Event-Name for ex. is then null. Maybe the instancevariable ba too...

I think that you don't need firebase-common.jar at all.
it is there but it is not referenced in Build-Path in Eclipse....

Or is the problem that the jars are available in the libs folder even if not referenced in Eclipse?


Licensed User
Or is the problem that the jars are available in the libs folder even if not referenced in Eclipse?
yes, it is. Removing the not used jar fixed the issue....
Ok, i now can start building a wrapper for B4J :D

Thank you very much, @Erel


Well-Known Member
Licensed User
I did and it's quite simple to send message, but to get unsollicited messages from Google server you need to register and the only supported environments seems to be Android, IOS(the most disturbing OS) and Chrome(and compatible browsers). The protocol is not revealed and if you sniff packets you are not able to decode them because they are encrypted.
Thank you Don. I don't know where you find time to give us such a valuable support. After giving school help to grandsons I have no time left to work! It's time to retire...
Ciao e grazie


Well-Known Member
Licensed User
Bidirectional messaging between an android device and a PC(running a B4J pgm). I have used direct comunication to write from Android to Android and it worked for months with no issue at all.
Forgive my English, last time I could practice was in october 2016!