Android Debugging- CrashReporter on Duty

Bal sikandar
Aug 5, 2017 · 2 min read

If someone asks me what do I do, I say: “I debug”.

Debugging is something very common for all developers. It’s the second stage of being a programmer. You got a problem, you solve it and you rock. Solving a bug gives us more pleasure than adding a feature and so many communities have evolved over the years by helping developers from all over the globe. By sharing, solving, debugging each other’s problems we have created a great learning environment.

It happens occasionally whenever we shared an APK for internal testing to our QA, the first response we get is “It’s crashing”, and when we try to reproduce, we can’t. So I made an effort to find a solution and came up with CrashReporter.

CrashReporter is a very handy tool to capture all your crashes and save them in a file locally.

Let me tell you how it works. Just add below mentioned dependency in your app’s gradle and you’re good to go.

compile 'com.balsikandar.android:crashreporter:1.0.9'

All the crashes that it captures are written to a file in your app’s Android/data/your-package-name/files/crashReports directory. If you want to save crash logs in your own path, add this snippet in your Application class’s onCreate method with the path as an argument.

CrashReporter.initialize(this, crashReportsPath);

Note: These files are saved with current date and time as filenames and “_crash” as suffix.

Crash Reporter not only captures crashes but also provides APIs to log your caught exceptions.

For example, following code segment is catching an exception and logging them in a file just like crashes. Files logged using logException API has “exception” as suffix in their name.

try{
//do your stuff
}catch(Exception e){
CrashReporter.logException(e);
}

Log Exception API

logException(Exception e)

Check the project here to start using in your projects.

Happy coding :)

Thanks for reading this article. Be sure to click ❤ below to recommend this article if you found it helpful. It means a lot to me.

For detailed queries check out this Github repo. Happy coding.

Also let’s connect on facebook, twitter, github and linkedin.

MindOrks

Our community publishes stories worth reading on Android…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store