1

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
J. Williams
  • 684
  • 1
  • 7
  • 17
  • Possible duplicate of [Trouble with logging my data with crashlytics](https://stackoverflow.com/questions/24336444/trouble-with-logging-my-data-with-crashlytics) – Andrii Omelchenko Nov 19 '17 at 13:53

2 Answers2

2

There isn't a way to report non-fatal events in the current session. The app needs to be restarted for non-fatal events to get reported to Crashlytics.

Alexizamerican
  • 3,294
  • 19
  • 15
  • That's correct. I managed to workaround this limitation by tricking Crashlytics into thinking that the app was restarted, but it's a dirty hack affordable only in tests. I hope that in the future Crashlytics team will add an optional feature of uploading crashes immediately. – J. Williams Nov 21 '17 at 20:49
0
import com.google.firebase.crash.FirebaseCrash;

FirebaseCrash.report(new Exception("Error in CreateMobileAlertNative "+e.getStackTrace()));

I used to get non-fatal exception on crashlytics by using this FirebaseCrash class, I put some codes on my catch,via which i used to get those reports, try this once.

saurabh yadav
  • 567
  • 6
  • 14