The previous Fabric SDK allowed a check like this
if (Fabric.isInitialized()) {
crashSetParam(CrashParameters.ROOT_NODE, nodeInfoCompat.toString())
Crashlytics.logException(ex)
}
I am unable to determine how to do this in the new Firebase Android SDK and it causes my junit tests that might touch this to crash. I realize I can wrap it in an interface, but I am also curious how to solve it in a simple manner like above. Thank you.
I logged an issue on github too:
https://github.com/firebase/firebase-android-sdk/issues/1437
Without a check we get something like this when running unit tests:
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process null. Make sure to call FirebaseApp.initializeApp(Context) first.
I've fixed it with the following for now:
fun logException(ex: Throwable, nodeInfoCompat: AccessibilityNodeInfoCompat?) {
// We check to make sure Fabric is initialized or else the tests will fail - see above comment
try {
FirebaseCrashlytics.getInstance().setCustomKey(CrashParameters.ROOT_NODE, nodeInfoCompat.toString())
FirebaseCrashlytics.getInstance().recordException(ex)
} catch (e: IllegalStateException) {
Timber.e(e);
}
}