'Firebase Admin - Uncaught exception in Firebase Database runloop (4.1.5)

I'm running an app on Firebase Admin. So this code worked the first time I ran it, but after a few weeks I tried it again and I've been getting this error after hours of debugging (RunLoop: Uncaught exception in Firebase Database runloop (4.1.5)). I've seen other ones with the runloop version as (3.0.0), but none of the errors match the one I have.

        InputStream serviceAccount = getAssets().open("<My JSON file goes here>");
        FirebaseOptions options = new FirebaseOptions.Builder()
                .setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
                .setDatabaseUrl("<My Firebase link goes here>")
                .build();

        FirebaseApp defaultApp = FirebaseApp.initializeApp(options);


        database = FirebaseDatabase.getInstance();
        database.setLogLevel(Logger.Level.DEBUG);
        database.getReference().child("test").setValue("test value");

For my gradle files, I only have these:

compile 'com.google.firebase:firebase-admin:4.1.5'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'

And here's more of the stack trace:

W/System.err: Mon Apr 03 11:39:33 GMT+08:00 2017 [ERROR] RunLoop: Uncaught exception in Firebase Database runloop (4.1.5). Please report to [email protected]
W/System.err: java.lang.NoSuchMethodError: No virtual method object()Lorg/json/JSONWriter; in class Lorg/json/JSONStringer; or its super classes (declaration of 'org.json.JSONStringer' appears in /system/framework/core-libart.jar)
W/System.err:     at com.google.firebase.database.util.JsonMapper.serializeJsonValue(JsonMapper.java:55)
W/System.err:     at com.google.firebase.database.util.JsonMapper.serializeJsonValue(JsonMapper.java:44)
W/System.err:     at com.google.firebase.database.util.JsonMapper.serializeJson(JsonMapper.java:24)
W/System.err:     at com.google.firebase.database.util.GAuthToken.serializeToString(GAuthToken.java:53)
W/System.err:     at com.google.firebase.database.core.JvmAuthTokenProvider.wrapOAuthToken(JvmAuthTokenProvider.java:110)

Any ideas what might be wrong?



Solution 1:[1]

The Firebase Admin SDK is not intended to be run in an Android app. It's only supported for standalone and server applications. For Android apps, you're supposed to use the regular Android SDK instead.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doug Stevenson