Why I don't see Logs in Firebase Crash Reporting

5.3k views Asked by At

I'm using Firebase Crash Reporting.

I saw here feature which is called Logs.

But how to use this?

I've Google Analytics in my project, and I'm trying to log crashes using FirebaseCrash.log() exactly in the same method.

public void sendGoogleAnalyticsEvent(String category, String label, String action) {
    Map<String, String> build = new HitBuilders.EventBuilder()
            .setCategory(category)
            .setLabel(label)
            .setAction(action)
            .build();
    tracker.send(build);
    FirebaseCrash.log("Category: " + category + " label: " + label + " action: " + action);
}

But I don't see any Logs in the crash. This guy speak about automatically logged events, I don't see this too. What is wrong ? enter image description here

UPDATE: If I select 'Analytics' from the Firebase menu, there everything is shown and works correctly

2

There are 2 answers

0
Wilik On BEST ANSWER

Make sure you are using the latest version of Firebase Crash Reporting SDK, currently 10.0.1

The log that will appear in Firebase Crash Reporting is imported from Firebase Analytics, so you have to use Firebase Analytics instead. source

compile 'com.google.firebase:firebase-core:10.0.1'

For example:

Bundle bundle = new Bundle();
bundle.putString("name", "button");
FirebaseAnalytics.getInstance(this).logEvent("button_click", bundle);

throw new RuntimeException("This is a crash");

the result is shown in this screenshot below

enter image description here

0
Martin B On

From documentation:

"To report caught exceptions, use report(Throwable).

To attach log messages to a crash report, use log(String) or logcat(int, String, String) at points during execution that will best help you know what happened prior to the crash."

// THIS IS ADDITIONAL INFORMATION SHOWN IN LOGS SECTION OF EACH ISSUE
FirebaseCrash.log("User selects Settings");
...

FirebaseCrash.log("User selects Enable BT");
...

In your caught exception handler:

// THIS SHOWS UP IN ISSUES IN CRASH REPORTING
Throwable t=new Throwable("BluetoothAdapter is null in init_BT()").fillInStackTrace();
FirebaseCrash.report(t);

Additionally, events logged with Firebase Analytics logEvent() on the user earlier will also show up in "Logs" for the issue as shown in the answer by Wilik.

Further analysis of crashes (from the Captech link below): "When a Crash Report is generated it is created with the "app_exception" event. This event can be used as a condition when creating an Audience in the Analytics dashboard..." [havenĀ“t tried this myself yet]

https://developers.google.com/android/reference/com/google/firebase/crash/FirebaseCrash https://www.captechconsulting.com/blogs/an-introduction-to-firebase-analytics-and-crash-reporting