Blog

We believe there is something unique at every business that will ignite the fuse of innovation.

AndroidAndroid has an ever-growing number of tools to detect application crashes and help developers fix these bugs. Here is a brief overview of some of the most popular ones and how to implement them.

Firebase

Firebase was bought by Google in 2014 when it provided a real-time database API. At Google I/O 2016, a new suite of Firebase products was announced in addition to rolling in some existing Google products. Firebase now includes features such as analytics, realtime databases, cloud messaging, authentication, file storage, and remote configuration. Android Studio 2.2 includes a Firebase tool for easier integration of their products.

Setup

compile 'com.google.firebase:firebase-crash:9.4.0'

Handled Exceptions

FirebaseCrash.report(exception);

Custom Logs

FirebaseCrash.log("Submit button clicked");

Pricing

Free for unlimited users

Gotchas

  • Does not have methods for logging custom key values or user data
  • Firebase does not have a method to force a crash
  • Where are known issues when an application extends the Application class

Crashlytics

Crashlytics was purchased by Twitter in 2013 and rolled into their suite of SDKs called Fabric.io. The Fabric suite includes tools for analytics, payments, A/B testing, ads, and more. Crashlytics allows you to log user information such as email and username as well as set custom key-value pairs. It can also be integrated with a number if issue trackers including Github, Gitlab, and JIRA.

Setup

The setup for Crashlytics is a little more complicated than it is for any of the other tools.

  • In your build.gradle file add this before your dependencies:
buildscript {
	repositories {
		maven { url 'https://maven.fabric.io/public' }
	}
	dependencies {
		// The Fabric Gradle plugin uses an open ended version to react
		// quickly to Android tooling updates
		classpath 'io.fabric.tools:gradle:1.+'
	}
	...
	apply plugin: 'io.fabric'
	repositories {
		{ url 'https://maven.fabric.io/public' }
	}
}
  • Then add your Crashlytics dependency:
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
	transitive = true;
}
  • Add this within the application tag of your AndroidMainfest.xml
<meta-data
	android:name="io.fabric.ApiKey"
	android:value="<FABRIC_API_KEY>"
/>
  • Finally, in the onCreate of either your launcher Activity or Application class add (user info optional):
Fabric.with(this, new Crashlytics());

Handled Exceptions

Crashlytics.logException(exception);

Custom Logs

Crashlytics.setUserName(user.user.getUserName());

//send key-value pairs
Crashlytics.setString("user_id", user.getUserId())
Crashlytics.setBool("is_user_logged_in", user.isLoggedIn())

Crashlytics.log("Submit button clicked");

Pricing

Crashlytics is free for all users.

Gotchas

Even though Crashlyitcs is gratis, it does come at a price. Twitter likely uses the data collected to gather data on apps and users.

Apteligent

Apteligent (formerly Crittercism) is an application health product focused on enterprise customers. In addition to tracking application crashes, users are also able to monitor performance, user flows, analytics, and more. Outside of crash reporting, the application has metrics that other products in this list do not offer. Apteligent can be integrated with Github, JIRA, and Pivotal Tracking. 

Setup

  • Add the dependency to your build.gradle
compile 'com.crittercism:crittercism-android-agent:+'
  • Add the permissions to your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
  • In the onCreate of Activity or Application onCreate
Crittercism.initialize(getApplicationContext(), "CRITTERCISM_APP_ID");

Handled Exceptions

Crittercism.logHandledException(exception);

Custom Logs

Crittercism.leaveBreadcrumb("Submit button clicked");

//user specific info
Crittercism.setUsername(user.getUserName());

// Apteligent allows you to send custom JSON objects as meta data
JSONObject metadata = new JSONObject();
metadata.put("user_id", user.getUserId());
metadata.put("is_user_logged_in", user.isLoggedIn());
Crittercism.setMetadata(metadata);

Pricing

Apteligent uses a freemium model. Crash reporting is included in the free version, but prices for plans with in-depth app heath monitoring start at $150/month.

Bugsnag

Bugsnag is a full stack crash reporting suite aimed at enterprise applications. It includes a number of features missing from other tools including Slack integration and an on-premise option. Bugsnag can be integrated with Github, Gitlab, and JIRA.

Setup

  • Add bugsnag to you dependencies in your build.gradle
compile 'com.bugsnag:bugsnag-android:+'
  • Add your API key to the <application> section of your AndroidManifest.xml
<meta-data
	android:name="com.bugsnag.android.API_KEY"
	android:value="API-KEY"
/>
  • In your main activity onCreate function, initialize to begin capturing exceptions
Bugsnag.init(this);

Handled Exceptions

Bugsnag.notify(exception);

Custom Logs

Bugsnag.leaveBreadcrumb("Submit button clicked");

//user specific data
Bugsnag.setUserEmail(user.getEmail());
Bugsnag.setUserId(user.getUserId());
Bugsnag.setUserName(user.getUserEmail());

//Bugsnag allows you to send custom key-value pairs 
HashMap<String, String> metadata = new HashMap<String, String>();
metadata.put("user_id", user.getUserId());
metadata.put("is_user_logged_in", user.isUserLoggedIn().toString());

Bugsnag.leaveBreadcrumb("Submit button clicked", BreadcrumbType.STATE, metadata);

Pricing

Bugsnag uses a freemium model based on number of reports per day, data retention, and features. The free plan includes 250 error reports per day with 7 days of retention, but does not include issue tracking integration. Paid plans start at $29/month (100k errors/60 days retention). There is also an enterprise plan that starts at $999/month.

Bottom line

Each crash reporting tool has pros and cons, so it is impossible to suggest just one for every application. Firebase does not have custom logging, but if you are already using Firebase for you app, it is easy to implement, and it is nice having all your application data (including analytics) in one console. Crashlytics is free, but who knows what Twitter is doing with your users' data. Apteligent has "app-health monitoring", but plans that include it are expensive. Bugsnag is expensive, has full stack solutions and an on-premise solution. No matter which tool you choose, hopefully this gives you better insight into which best suits your needs.

About the Author

Kevin BojarskiKevin is a Software Engineer in CapTech’s Richmond office, where he specializes in architecting and building enterprise Android applications for clients.