


When you see your app crash and close, the basic steps for diagnosing and resolving this are outlined below: Search stackoverflow for posts about the same issue.Īrmed with this mindset and the above principles, let's take a look at how to debug and investigate issues that arise within our apps. Visit the issue tracker for the component you are seeing issues with. Search Google for the behavior using any descriptive identifiers. If you are running into a major unexpected issue, you are probably not alone. Comment out or remove extraneous code that could be complicating the issue. Try to isolate or reduce the code surrounding the issue and figure out the simplest way to reproduce what’s occurring. Before assuming the code is broken, try restarting the emulator, trying the app on a device and/or fully re-building the app. Convince yourself that there is an issue in the code that can be repeatedly reproduced by following the same steps. The following high-level principles should be applied when faced with an unexpected app behavior during investigation:

This is entirely normal as a mobile engineer. Often you may find yourself on some days spending more time debugging crashes or unexpected behavior then writing new code. Debugging is a vital part of the software development process.Debugging is an opportunity to understand your app better than you did before and hopefully sharpen your ability to write correct code in the future by programming defensively. Think of debugging as an opportunity to fill gaps in knowledge.This is contrast to compile-time errors which prevent an app from running and are often easier to catch. This class of issues are known as runtime errors. Just because a program runs, doesn’t mean it’s going to work as you expected.A few key principles about debugging are captured below: In addition, you'll often find yourself in the role of a coding investigator in order to understand where and why an app is crashing or not working as expected. Debugging MindsetĪs an Android developer, you'll need to cultivate a "debugging mindset" as well as build up defensive programming practices that make writing error-prone code less likely. Refer to our guide below and/or these debugging slides for more a detailed look at debugging crashes and investigating unexpected problems with your app. You know you have experienced a runtime exception when you see this in your emulator or device:ĭon't worry though! This is totally normal and there's a specific set of steps you can take to solve these. When building Android apps, your app is bound to crash from time to time or exhibit strange unexpected behavior.
