I am trying to start a Java client from scratch, and have pulled in firebase-client-jvm:2.2.1 in gradle. I get the following in a stack trace while trying to compile anything that includes the com.firebase.client.Firebase class:
java.lang.RuntimeException: java.lang.NoClassDefFoundError: Unable to load class com.firebase.client.Firebase due to missing dependency android/content/Context
at org.codehaus.groovy.control.CompilationUnit.convertUncaughtExceptionToCompilationError(CompilationUnit.java:1083)
...
Caused by: java.lang.NoClassDefFoundError: Unable to load class com.firebase.client.Firebase due to missing dependency android/content/Context
I have no desire to include anything to do with Android, and all of the answers I find state that firebase "supports both" (i.e. Get Firebase to work with java, not Android), but I do not know how to get going.
I cannot find examples or tutorials online showing a "simple" Java-only client, and would appreciate any "getting started" help.
UPDATE: Not only did I have to create the android.context.Context class, I had to give up on writing the program in Groovy. When I switched it back to a Java project it seemed to smooth things out considerably.
This is a known bug of the Firebase library with dynamic languages on the JVM. There is an easy workaround: Create an empty dummy class Context in the package android.content. The class is not used at runtime, however the class loader expects it to be present.
See: https://groups.google.com/forum/#!msg/firebase-talk/XLbpLpqCdDI/ncuw32Xr-4YJ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With