Skip to main content

Integrating Crashlytics to monitor your Android app’s health

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.

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.

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.
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:
implementation('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.
(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(); Crashlytics.setUserName(); Crashlytics.setUserEmail();
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.
_________________________________________________________________________________
Happy Coding...

Comments

Popular posts from this blog

Get Phone Number from Contact List - Android Tutorial

When you create an application to send sms or an application to make calls, getting a destination number from the contacts list is a common task. In this Android tip, I am going to show the code to fetch a number from the contacts list. Now let me tell you how to achieve the goal. First, you need to create an Intent object for the PICK_ACTION action. To open the contacts list, the table that contains the contacts information must be specified as a parameter of the constructor of the Intent class. You can refer to the table using ContactsContract.Contacts.CONTENT_URI. Then call the startActivityForResult () method passing the Intent object and request code to open the contacts list. After a contact is selected from the contacts list, to get the result, you need to override the onActivityResult(int reqCode, int resultCode, Intent data) method of the activity. You can call the getData() method of the data parameter to get the table or uri that contains the selected contact. From the t

Spinner with Search on DropDown - Android Tutorial

If you have more values on Dropdown of Spinner its hard to select the last item by making a long scroll. To overcome this issue Android introduced a component called  AutoCompleteTextView Yes it is!!! Then why Spinner with Search? There may be some requirement even though gave much knowledge about it. There is a simple and good library that helps us to achieve this -  SearchableSpinner Gradle dependencies {     ...     implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1' } Usage Now replace your Normal Android Spinner on XML with the following < com.toptoche.searchablespinnerlibrary.SearchableSpinner     android:id="@+id/id_city"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:background="@android:color/transparent"     android:padding="5dp" /> ___________________________________________________________

Set Focus on Spinner when select Item on Vertical Scroll - Android Tutorial

We may face an issue on Spinner lies on long vertical scroll, (i.e.) when selected and item from dropdown the focus moves to top of scroll. To avoid this please follow this piece of code spinner.setFocusableInTouchMode( true ); spinner.setOnFocusChangeListener( new View.OnFocusChangeListener() {     @Override     public void onFocusChange(View v, boolean hasFocus) {         if (hasFocus) {             if (spinner.getWindowToken() != null ) {                 spinner.performClick();             }         }     } });   _______________________________________________________________________________ Happy Coding...