FirebaseRealtimeDatabase4J

DonManfred

Expert
Licensed User
Longtime User
Not me, sorry.
 

DonManfred

Expert
Licensed User
Longtime User
But i found out that

See http://mvnrepository.com/search?q=com.google.firebase:firebase-admin

1. Firebase Server SDK Library4 usages
com.google.firebase » firebase-server-sdkCOMMERCIAL

DEPRECATED - please use com.google.firebase:firebase-admin instead. DEPRECATED. This is the official server SDK for Firebase. Build extraordinary native JVM apps in minutes with Firebase. The Firebase platform can power your app’s backend, user authentication, static hosting, and more.



the sdk i started building the lib with is deprecated :-(

Now there is a second one instead. firebase-admin

http://mvnrepository.com/artifact/com.google.firebase/firebase-admin/4.0.3

i do add a server app for this in the fb-console and downloaded the json required....

I got the below code shown after i seup the server-key.

B4X:
FirebaseOptions options = new FirebaseOptions.Builder()
  .setServiceAccount(
    new FileInputStream("path/to/serviceAccountKey.json"))
  .setDatabaseUrl("https://tactical-patrol-603.firebaseio.com")
  .build();

FirebaseApp.initializeApp(options);
Using a valid FirebaseApp-Init i guess we should be able to get an FirebaseDatabaseReference from the app-instance

Will look at this (replacing the old server jar with this jar (see downloadlonk above)
 

jmon

Well-Known Member
Licensed User
Longtime User
the sdk i started building the lib with is deprecated :-(
Thank you for telling me! I was working on it just now. I'll switch to the new sdk and see if I can do something with it. :)

[edit] this page explains very clearly the dependencies needed!
 

jmon

Well-Known Member
Licensed User
Longtime User
I don't get it, I've tried so many imports, but I can't get passed this error:
C:\Users\net\Desktop\tempjars\credentials.json
Tue Dec 27 14:54:47 ICT 2016 [ERROR] RunLoop: Uncaught exception in Firebase Database runloop (3.0.0). Please report to [email protected]
java.lang.NoSuchMethodError: org.json.JSONStringer.object()Lorg/json/JSONWriter;
at com.google.firebase.database.util.JsonMapper.serializeJsonValue(JsonMapper.java:55)
at com.google.firebase.database.util.JsonMapper.serializeJsonValue(JsonMapper.java:44)
at com.google.firebase.database.util.JsonMapper.serializeJson(JsonMapper.java:24)
at com.google.firebase.database.util.GAuthToken.serializeToString(GAuthToken.java:53)
at com.google.firebase.database.core.JvmAuthTokenProvider$1.onComplete(JvmAuthTokenProvider.java:40)
at com.google.firebase.tasks.OnCompleteCompletionListener$1.run(OnCompleteCompletionListener.java:37)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
It keeps on telling me that I don't have JSONWriter, but I'm quite sure I have it, it's in the json-20160212.jar ! I can see it listed in when I open it with 7zip.

For the moment I've added all those dependencies (most of them from "google-api-java-client"), but no luck:
B4X:
@DependsOn(values={"firebase-admin-4.0.3",
    "json-20160212",
    "commons-logging-1.1.1",
    "google-api-client-1.21.0",
    "google-api-client-android-1.21.0",
    "google-api-client-appengine-1.21.0",
    "google-api-client-gson-1.21.0",
    "google-api-client-jackson2-1.21.0",
    "google-api-client-java6-1.21.0",
    "google-api-client-protobuf-1.21.0",
    "google-api-client-servlet-1.21.0",
    "google-api-client-xml-1.21.0",
    "google-http-client-1.21.0",
    "google-http-client-android-1.21.0",
    "google-http-client-appengine-1.21.0",
    "google-http-client-gson-1.21.0",
    "google-http-client-jackson-1.21.0",
    "google-http-client-jackson2-1.21.0",
    "google-http-client-jdo-1.21.0",
    "google-http-client-protobuf-1.21.0",
    "google-oauth-client-1.21.0",
    "google-oauth-client-appengine-1.21.0",
    "google-oauth-client-java6-1.21.0",
    "google-oauth-client-jetty-1.21.0",
    "google-oauth-client-servlet-1.21.0",
    "gson-2.1",
    "guava-jdk5-17.0",
    "httpclient-4.0.1",
    "httpcore-4.0.1",
    "jackson-core-2.1.3",
    "jackson-core-asl-1.9.11",
    "jdo2-api-2.3-eb",
    "jetty-6.1.26",
    "jetty-util-6.1.26",
    "jsr305-1.3.9",
    "protobuf-java-2.4.1",
    "transaction-api-1.1",
    "xpp3-1.1.4c"})

But I think at the end, the list of dependencies could be just this:
B4X:
@DependsOn(values={"guava-jdk5-17.0",
"firebase-admin-4.0.3",
"json-20160212",
"google-http-client-gson-1.21.0",
"google-http-client-1.21.0",
"gson-2.6.2",
"google-api-client-gson-1.21.0",
"google-api-client-1.21.0","google-oauth-client-1.21.0"})
Any idea why I can't get passed the missing JSON writer? I've attache the source in it current state. Thanks
 

Attachments

  • src.zip
    10 KB · Views: 389

DonManfred

Expert
Licensed User
Longtime User
my tests are using

B4X:
@DependsOn(values={
        "json-1.5-20090211",
        "guava-jdk5-17.0",
        "firebase-admin-4.0.3",
        "gson-2.8.0",
        "google-api-client-1.22.0",
        "google-api-client-gson-1.22.0",
        "google-http-client-1.22.0",
        "google-http-client-gson-1.22.0"
})

and

B4X:
#AdditionalJar: json-1.5-20090211
#AdditionalJar: guava-jdk5-17.0
#AdditionalJar: firebase-admin-4.0.3
#AdditionalJar: gson-2.8.0
#AdditionalJar: google-api-client-1.22.0
#AdditionalJar: google-api-client-gson-1.22.0
#AdditionalJar: jackson-core-2.8.5
#AdditionalJar: google-oauth-client-1.22.0

but i run always into
B4X:
Program started.
E:\B4J\Projekte\FIREBA~1\Objects\credentials.json
Tue Dec 27 09:16:17 CET 2016 [ERROR] RunLoop: Uncaught exception in Firebase Database runloop (3.0.0). Please report to [email protected]
java.lang.NoSuchMethodError: org.json.JSONStringer.object()Lorg/json/JSONWriter;
    at com.google.firebase.database.util.JsonMapper.serializeJsonValue(JsonMapper.java:55)
    at com.google.firebase.database.util.JsonMapper.serializeJsonValue(JsonMapper.java:44)
    at com.google.firebase.database.util.JsonMapper.serializeJson(JsonMapper.java:24)
    at com.google.firebase.database.util.GAuthToken.serializeToString(GAuthToken.java:53)
    at com.google.firebase.database.core.JvmAuthTokenProvider$1.onComplete(JvmAuthTokenProvider.java:40)
    at com.google.firebase.tasks.OnCompleteCompletionListener$1.run(OnCompleteCompletionListener.java:37)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

So, basically the same problem but using some imports less...
 

jmon

Well-Known Member
Licensed User
Longtime User
So, basically the same problem but using some imports less...
Yep, I tried importing everything just to make sure the error was not caused by not importing something from Google API Java :)

I tried importing "org.json-2.0.jar" but same problem...

By the way, I see that you imported "json-1.5-20090211" but I don't think it's the latest version of the library. It seems wrongly listed as an update on this page http://mvnrepository.com/artifact/com.google.firebase/firebase-admin/4.0.3
but when looking at this page http://mvnrepository.com/artifact/org.json/json
the latest version (date) is "json-20160810.jar"

[edit] also tested with older versions of firebase-admin-4.0.(0,2,3).jar and same problem
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
Reporting something I found: from this website: https://jar-download.com/?search_box=Firebase (Firebase Database is the 2nd result in the page)
I downloaded all the required dependencies as a zip file, and this is the list of dependencies:
B4X:
@DependsOn(values={"commons-codec-1.3",
    "commons-logging-1.1.1",
    "firebase-admin-4.0.3",
    "google-api-client-1.21.0",
    "google-api-client-gson-1.21.0",
    "google-http-client-1.21.0",
    "google-http-client-gson-1.21.0",
    "google-http-client-jackson-1.21.0",
    "google-oauth-client-1.21.0",
    "gson-2.7",
    "guava-jdk5-17.0",
    "httpclient-4.0.1",
    "httpcore-4.0.1",
    "jackson-core-2.1.3",
    "jsr305-1.3.9"})
Though adding this list of dependencies doesn't fix the "org.json.JSONStringer" problem

[edit] I will try sending an email to the Google address given in the error message, let's see what come out of this
 
Top