#AndroidDev #Tip 3 – Don’t leave any exceptions behind

By -

I have observed in most of the android applications code that we android developers used to only print stack trace and used to ignore exceptions.

For example:

try {
   ...
   ...
   // some code that throws exceptions
   ...
   ...
} catch (Exception e) {
   e.printStackTrace();
}

This is not a standard solutions, you should not just print the log stack trace because you won’t be able to get such exceptions in release build or from your user’s phone.

Ideally you should handle it or log it somewhere or get it reported automatically, so you can look into the issue later in future and can see what was happened and what went wrong!

To do so, I used to log exceptions using Crashlytics using:

Crashlytics.logException(exception);

All logged exceptions will appear as “non-fatal” issues in the Fabric dashboard. Your issue summary will contain all the state information you use to get from crashes along with breakdowns by Android version and hardware device.

Now if you ask me a question, won’t it be an overhead on network and performance? It will be minimal impact since Crashlytics processes exceptions on a dedicated background thread, so the performance impact to your app is minimal.

Paresh Mayani

Lazy android developer, exploring the horizon of android development since 7 years, currently working as a Technical Lead - Android at Simform Solutions, India. Former Application Architect at KarConnect. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

Loading Facebook Comments ...
Loading Disqus Comments ...