问题描述:

I want to use firebase admin in my java application. On the website it says I can add it via gradle or maven. But I don't want to do that. Instead I downloaded the jar file from maven central repository website and added it as a library to my project. I added the code as stated on the firebase guides section and run the application and I get the following output;

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException

at error.myclass.main(myclass.java:17)

Caused by: java.lang.ClassNotFoundException: org.json.JSONException

at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

... 1 more

So I tried adding libraries to fix the problem, and every time I run the application I just got another error. These are the libraries I have currently added:

com.google.guava_1.6.0.jar

firebase-admin-4.0.3.jar

google-api-client-1.4.1-beta.jar

google-api-client-gson-1.22.0.jar

google-api-java-client-ext.jar

google-http-client-1.16.0-rc.jar

java-json.jar

Now the only error I get is this:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.api.client.json.gson.GsonFactory.getDefaultInstance()Lcom/google/api/client/json/gson/GsonFactory;

at com.google.firebase.FirebaseOptions$Builder.setServiceAccount(FirebaseOptions.java:76)

at MyClass.cool.main(cool.java:18)

I have correctly added all of the libraries so I do not understand why this is not working. So my question is how do I successfully add firebase admin to a java project in eclipse without using gradle or maven.

相关阅读:
Top