Integrating Crashlytics to monitor your Android app’s health

Miguel Montemayor
Clover Platform Blog
4 min readJul 6, 2017

Crash monitoring tools help developers build, deploy, and maintain high-quality apps. These tools can alert you to new issues in real-time. The quicker you learn about new issues, the sooner you can get a fix to your users. There is also an opportunity to proactively reach out to users impacted by ongoing issues. All developers should implement some form of crash reporting to monitor the health of their apps.

This article will guide you through quickly setting up crash monitoring with Crashlytics in your current Android app.

Crashlytics email notification when a new fatal app crash is detected

There are many alternative tools you can use for crash monitoring, but Crashlytics–a Fabric service owned by Google–is one of the most popular and widely used. Crashlytics’ integration is easy–even for novice developers. It is completely free. The reporting is customizable and detailed. There’s good documentation and support.

While other crash reporting tools may be more suitable for your needs, it’s important note that some tools like Firebase require Google Play services, which some AOSP-based OS’s do not have (e.g., Clover and Amazon Fire).

These instructions are based on the Crashlytic’s installation guide. For additional reference, here’s a sample Clover app in my GitHub repository.

Signing up for Fabric and getting your API key

Before starting to integrate, you’ll need to sign up for a free Fabric account. After you confirm your email, you will be redirected to an onboarding page that will ask you, “What platform are you building for?” You can ignore this onboarding page.

Once you reach this page, you can ignore it and return to this guide. You do not need to install the Android Studio plug-in.

If you have a new account, you will be unable to access your Dashboard to get your API key. You’ll be redirected to the onboarding page. However, on Crashlytic’s installation guide, while logged in you can find your API key in the “Add Your API Key” section.

Install with Gradle

The installation is pretty simple. You will need to add the following code snippets below to these project files: build.gradle, AndroidManifest.xml, and MainActivity.java.

build.gradle

In your build.gradle app module, you will need to add four code snippets.
1. Add the following buildscript:

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}

2. Apply the Fabric plugin:

apply plugin: 'io.fabric'

3. Add the Fabric Maven repository:

repositories {
maven { url 'https://maven.fabric.io/public' }
}

4. Add the following to your dependencies:

compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}

AndroidManifest.xml

Add your API key to the AndroidManifest.xml file:

<meta-data
android:name="io.fabric.ApiKey"
android:value="<YOUR_FABRIC_API_KEY>"
/>

Request permission for your application to open network sockets:

<uses-permission android:name="android.permission.INTERNET" />

MainActivity.java

In the MainActivity.java file, import the following:

import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;

In your onCreate() method, add:

Fabric.with(this, new Crashlytics());

At this point, you should be able to build your app without errors. If you have additional questions, you can refer to my sample app on GitHub.

(Optional) To log user information that will be displayed on crash reports, you will need to add one or any combination of the following in your app (see sample):

Crashlytics.setUserIdentifier(<USER_ID>);                Crashlytics.setUserName(<USER_NAME>);
Crashlytics.setUserEmail(<USER_EMAIL>);

After setting up Crashlytics and deploying your updated app, you should get an email from Fabric letting you know a new app has been detected.

Crash Notifications & Reports

By default, notifications are sent out when new issues are detected or issues are regressed. You can customize these settings. However, I recommend leaving important notifications on.

The Crashlytics Dashboard lets you monitor the health of your app in real-time. It shows you details like number of crashes, percentage of crash-free users, and which users are impacted by each crash; so you are able to identify and prioritize bug fixes.

If you log user information with Crashlytics, you can identify specific users impacted by certain crashes. You can provide proactive outreach acknowledging active issues and sharing possible workarounds.

It’s a no-brainer that every app developer should integrate with a crash monitoring tool like Crashlytics. You can get started quickly and easily with crash monitoring. With minimal work, app developers have real-time insights of their app’s performance. Get notified of recent issues and see how many users are impacted.

--

--