Get Firebase to work with java, not Android

I am trying to run the libgdx project and want to use firebase to log in the user. I find that the SimleLogin class is dependent on Android.jar. Is there any way around this, as I would like to have a java desktop application as well as an android.

Here is the code causing the problem:

SimpleLogin authClient = new SimpleLogin(myRef);; authClient.createUser(" myuser@gmail.com ", "much wow", new SimpleLoginAuthenticatedHandler() { @Override public void authenticated(FirebaseSimpleLoginError error, FirebaseSimpleLoginUser user) { if (error != null) { System.out.println(error); } else { System.out.println(user); } } }); 

And this drops it at runtime:

 Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoClassDefFoundError: android/net/Uri at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120) Caused by: java.lang.NoClassDefFoundError: android/net/Uri at com.firebase.simplelogin.SimpleLogin.makeRequest(SimpleLogin.java:634) at com.firebase.simplelogin.SimpleLogin.createUser(SimpleLogin.java:417) at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:63) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114) Caused by: java.lang.ClassNotFoundException: android.net.Uri at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 5 more 

Am I going about this or is it a Java platform that they claim to support really just android?

+6
source share
2 answers

Firebase Java has two parts, each of which has different dependencies:

Firebase Java client library . Use this to access a real-time Firebase database.

The docs are slightly Android-oriented, but work fine in Java and languages ​​that Java can invoke (like Groovy)

Firebase Simple Login library . This makes authorization easier, but you can handle auth yourself if you want.

This library is for Android only. In general, authentication usually ends with a bunch of platform-specific tricks. This library focuses on the Android sets of these tricks.

It looks like you want auth in libgdx. Can you expand your question to include a little more about your expected use case?

(copied from @Ossama comment above)

+5
source

The Firebase client comes in two flavors. One is Android, and the other is for the JVM. Unfortunately, by default you will only get the version for Android.

You will learn the JVM version from the change log.

September 24, 2015 - Version 2.4.0 ( Android ) ( JVM )

I think using a JVM jar will solve this problem.

Old comments: Use the following jar for the Java SDK https://cdn.firebase.com/java/firebase-client-jvm-2.4.0.jar

I got the link https://www.firebase.com/docs/android/changelog.html

+2
source

Source: https://habr.com/ru/post/973522/


All Articles