I'm running my instrumented tests on Firebase Test Lab and want non-fatal exceptions to be reported to Crashlytics.
However, calling Crashlytics.logException()
doesn't send the report immediately. After enabling core.debuggable(true)
I see this when sending report:
D/CrashlyticsCore: Crashlytics is logging non-fatal exception "java.lang.Throwable: java.lang.Throwable" from thread main
But the report is not visible on Crashlytics dashboard until I restart the app, and then I see:
D/CrashlyticsCore: Checking for crash reports...
D/CrashlyticsCore: Found crash report /data/user/0/.../files/.Fabric/com.crashlytics.sdk.android.crashlytics-core/nonfatal-sessions/....cls
D/CrashlyticsCore: Attempting to send 1 report(s)
D/CrashlyticsCore: Adding single file ....cls to report ...
D/CrashlyticsCore: Sending report to: https://reports.crashlytics.com/spi/v1/platforms/android/apps/org.dasfoo.delern.instrumented/reports
D/CrashlyticsCore: Create report request ID: null
D/CrashlyticsCore: Result was: 202
I/CrashlyticsCore: Crashlytics report upload complete: ...
D/CrashlyticsCore: Removing report at /data/user/0/.../files/.Fabric/com.crashlytics.sdk.android.crashlytics-core/nonfatal-sessions/....cls
D/CrashlyticsCore: Checking for crash reports...
D/CrashlyticsCore: No reports found.
This is not ideal for production use cases, but it will at least work when user restarts the app. In tests, this never works because Firebase Test Lab does not restart the app (restarting the app means tests will fail).
Is there any workaround to allow Crashlytics to send non-fatal reports from the instrumented tests?
Used packages:
com.crashlytics.sdk.android:crashlytics:2.6.8@aar
io.fabric.tools:gradle:1.24.0
UPD: rephrased the question and title. I am looking for an option to alter Crashlytics default behavior, since it seems like a reasonable feature to have.