{
  "$type": "site.standard.document",
  "canonicalUrl": "https://segunfamisa.com/posts/firebase-crash-reporting",
  "description": "Exploring the new crash reporting feature of Firebase",
  "path": "/posts/firebase-crash-reporting",
  "publishedAt": "2016-05-26T10:05:30.000Z",
  "site": "at://did:plc:a5mekodp4afxadlpr4hp2wci/site.standard.publication/3mm2oa7vz5327",
  "tags": [
    "android",
    "firebase",
    "crash reporting"
  ],
  "textContent": "<p align=\"center\">\n\t<img src=\"/images/firebase-icon.png\">\n</p>\n\nUpdate: (21st of September, 2016)  \nSince publication of this post, Firebase has changed and evolved, and this post has been updated to the new state of things.\n\nLast week, at Google I/O, Google announced a\nnumber of interesting new features in Firebase. The new Firebase is said to be a _\"Unified app platform for mobile developers\"_\nadding new tools to help develop faster, improve app quality, engage users and monetize apps. You\ncan check out this intro video here.\n\nSome of the new features in the Firebase upgrade include:  \n  1. Firebase Analytics.  \n  2. Firebase Cloud Messaging.  \n  3. Firebase Test Lab and Crash Reporting.  \n  4. Firebase Notifications, Dynamic Links, App Indexing, AdWords, Firebase Invites etc  \n\nI've been playing around the new product and it's been amazing. In this post, I'm\ngoing to show you how to use Firebase for Crash reporting in order to improve the\nquality of apps that you ship.\n\nHow to use?\nThe new Firebase works with the new Google Play Services 9.0, and to use it in Android Studio,\nyou need to follow these steps:  \n\nSetup Firebase\n\n1. Pre-requisites\nEnsure your development environment meets the pre-requisite requirements. The Pre-requisites as seen here are:\n\n   An Android device running Google Play services 9.0.0 or later  \n   The Google Play services SDK from the Android SDK Manager  \n   Android Studio 1.5 or higher  \n   An Android Studio project and its package name.\n\n2. Add Firebase to your app\nNext step is to add Firebase to your app. To do this, you need to create a project\non the Firebase console.  \n\n   Click on Create New Project (if you're starting a new project) or import Google Project\nif you're importing an existing project, and follow through the steps.  \n   Now, within your app, click on click on Add Firebase to your Android app.  \n\nYou'll be prompted to add your package name, and also to download a config file.\nThis is the usual google-services.json file. Be sure to add it to your app module's directory.\n(e.g /app)\n\n3. Add the SDK to your app\nTo use Firebase in your app, you need to add and setup the SDK within your Android app.  \nFirst, include the following lines to your root-level build.gradle file:\n\nAnd then at your app-module's build.gradle file, apply the google services plugin at\nthe bottom of the file.  \nYour build.gradle should look like this:\n\nReporting crashes\nFirebase Crash reporting automatically reports fatal errors (unhandled exceptions) once the dependency has been added and configured.\n\nIt requires NO line of code.\n\nReport non-fatal exceptions.\nFirebase allows you to manually report handled non-fatal (i.e exceptions that do not cause app crash).\nIt's always good to report any errors that happen, whether or not they cause a crash\n\nAfter a few minutes (it now takes about 2 minutes), the crash will appear on the console dashboard looking like:\n\n<p align=\"center\">\n\t<img src=\"/images/firebase-crash-dashboard.png\">\n</p>\n\nCreating logs with Firebase\nThere are other interesting things to do with Firebase crash reporting.\n\nYou can create custom logs for events in the reports. Usually, when you get a crash in your app, the next thing you want to find out is, what the user was trying to do right?\nWell, creating logs make that easy to do. You can create a log using a line like:\n\nYou can also make that log show on your logcat, use:\n\nError Clusters\nOne really cool thing about Firebase crash reporting is the _Cluster_ feature. Basically,\nfirebase arranges errors in clusters of similar stack traces and by the severity of impact on your users.\n\nEssentially, it groups by whether or not they are \"fatal\" errors and whether or not they have similar stack traces. This makes easy overview and prioritising possible.\n\nProguard Mappings\nFirebase allows you upload your proguard mappings if you have used proguard to secure your app.\nThis will enable Firebase handle the deobfuscation of crash reports, so that you can make sense out of it.\n\nIssues?\nFirebase crash reporting is still in Beta, so, there are definitely some issues for now,\nand I hope they continue to improve the product.\n\n  * While debugging my test app while writing this post, I noticed something strange, the\ncrash reporting seems to be a separate process, as seen in the screenshot below:\n\n<p align=\"center\">\n\t<img src=\"/images/firebase-background-process.png\">\n</p>\n\nThis may lead to some concurrency issues, and It's filed under the known issues here https://firebase.google.com/docs/crash/android#known-issues\n\nClosing.\nIn summary, I think the Firebase crash reporting is a pretty neat feature of the new Firebase product,\nand I look forward to it getting more matured, and stable.\n\nI intend to try out the other new parts of Firebase and share my findings.\n\nIf you have thoughts, suggestions, or corrections to share, please feel free to drop a comment below or tweet at me :)\n\nSincerely,  \nSegun.",
  "title": "Crash reporting in Firebase"
}