Once you ship your app into the wild you have real users using your app, Firebase has Crashlytics that allow you to understand the end user experience in production.

Firebase Crashlytics is now available to all Firebase developers. So if you’re an existing Firebase developer, you test out Crashlytics and upgrade.

Crashlytics is the market leader for crash reporting used by hundreds of thousands of developers their applications and installed in over 2.5 billion devices. Firebase brings Crashlytics into one unified console so it can truly work better together with all the other Firebase products.

As a developer, you want to get the bottom of the crash

 Firebase Crashlytics What you really want is a crash reporting tool that can take that crash, along with all the other crashes that are happening in the app, group them, prioritize them, give you an idea of how your app is doing stability-wise, release over release. Crash-per-user One great measure of that is looking at your crash-per-users statistic.If your apps are getting more stable or less stable release over release and all these crashes prioritize them into issues and issues are ranked by the number of times they are occurring and the number of devices that they are occurring on. Issues list You can clearly see here the line of code that crashed, the file name, and even do things like call up interesting bits of information, like maybe this crash is only occurring on ios 11.So maybe that’s indicative of something changing in the latest release, maybe deprecated API that you’re not supposed to be using anymore.It lets you know that maybe this crash is only occurring on rooted or jailbroken devices.That could indicate that someone’s using your app in a way that you didn’t intend.So maybe you don’t want to fix this crash.Just a couple of quick things there to really help you know that just to get a better idea of what you’re going to be getting into in solving this crash. Issues Detail Now, diving even deeper, you’ll see that you get this Issue detail page.so now you can see the full, now symbolicated or unobfuscated stack trace.you’ll see how the crash has been trending, version by version.You can see an operating system or device breakdown. Realtime alerting emailFirebase will alert you in real time, via email, the second a new issue arises.Firebase’ll let you know when a new issue arises not only new issues but also regressed issues.So if you close an issue, you think you’re all good and then we see that pop up on a new version, Firebase’ll let you know immediately about that. Velocity alerts are when one issue is causing a statistically significant portion of all sessions to crash.So this may indicate that you need to issue a hotfix right away or roll back because something really wrong is happening with your application and you get all this out of the box.This is with crash reporting.

Get started with Firebase Crashlytics


Firebase Crashlytics can work with the very little setup on your part—as soon as you add the SDK, Crashlytics gets to work sending crash reports to the Firebase console. To get started with Firebase Crashlytics, you need an app with Firebase enabled.

  • Click Tools > Firebase to open the Assistant window.
  • Click to expand one of the listed features (for example, Analytics), then click the provided tutorial link (for example, Log an Analytics event).
  • Click the Connect to Firebase button to connect to Firebase and add the necessary code to your app.

 Enabled Firebase in android app

Add the Crashlytics SDK to your project


1.Add the Crashlytics repositories and dependency to your project-level build.gradle file:

buildscripts {
    repositories {
        // ...
        maven {
           url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        // ...
        classpath 'io.fabric.tools:gradle:1.24.4'
    }
}
allprojects {
    // ...
    repositories {
       // ...
       maven {
           url 'https://maven.google.com/'
       }
    }
}

2.Add the Crashlytics dependencies to your app-level build.gradle:

apply plugin: 'io.fabric'
dependencies {
    // ...
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
       transitive = true
    }
    compile 'com.google.firebase:firebase-core:11.4.2'
}

Customize your Firebase Crashlytics crash reports


For more fine-grained control of your crash reports, customize your Crashlytics SDK configuration. For example, you can add logs to track down pesky bugs, and more.

1.Retracing a user’s steps with logs


On Android, use Crashlytics.log to help pinpoint issues. Crashlytics.log can write logs to a crash report and with Log.println(), or just to the next crash report:

  • Crash report and Log.println:
Crashlytics.log(int priority, String tag, String msg);
  • Crash report only:
Crashlytics.log(msg);

Crashlytics limits logs to 64kB. Crashlytics deletes older log entries if a session’s logs go over that limit.

2.Finding Contextual cues with keys


Sometimes it’s not just about the order of operations that causes the crash.It’s actually the context that the user is in.Here’s an example where I’m recording the key value.

Crashlytics.setString(key, value);
Crashlytics.setBool(String key, boolean value);
Crashlytics.setDouble(String key, double value);
Crashlytics.setFloat(String key, float value);
Crashlytics.setInt(String key, int value);

Re-setting a key updates its value, for example:

Crashlytics.setInt("current_level", 3);
Crashlytics.setString("last_UI_action", "logged_in");

Crashlytics supports a maximum of 64 key/value pairs. Once you reach this threshold, additional values are not saved. Each key/value pair can be up to 1 kB in size.

Log non-fatal exceptions


Crashlytics lets you log non-fatal exceptions.On Android, that means you can log caught exceptions in your app’s catch blocks:

try {
    methodThatThrows();
} catch (Exception e) {
    Crashlytics.logException(e);
    // handle your exception here
}

All logged exceptions appear as non-fatal issues in the Firebase console. The issue summary contains all the state information you normally get from crashes, along with breakdowns by Android version and hardware device. Crashlytics processes exceptions on a dedicated background thread, so the performance impact to your app is minimal. To reduce your users’ network traffic, Crashlytics batches logged exceptions together and sends them the next time the app launches.

 

Crashlytics only stores the most recent 8 exceptions in a given app session. If your app throws more than 8 exceptions in a session, older exceptions are lost.

Set user IDs


To diagnose an issue, it’s often helpful to know which of your users experienced a given crash. Crashlytics includes a way to anonymously identify users in your crash reports. To add user IDs to your reports, assign each user a unique identifier in the form of an ID number, token, or hashed value:

void Crashlytics.setUserIdentifier(String identifier);

If you need to clear a user identifier after you set it, reset the value to a blank string. So these are a few tips with Crashlytics and how you can get the most out of crash reporting.