How to diagnose the Android App Crashes and fix it?

 Android App Crashes : What to do? 

When app crashes ? 

- whenever there is an unexpected exit caused by an unhandled exception or signal.
- app written in java crashes if it throws unhandled exception, represented by the Throwable class.
- app written in native-code crashes if there is an unhandled signal, SIGSEGV, during the execution.
- app running in background can also crash ex. broadcast receivers & content providers running in background can cause the app to crash


How do you detect your crashes ?

- Android Vitals in Play Console is the tool that alert you with all the crash reports.

How to diagnose the crashes ? 

- most important thing is to find the root of the crash
- Situation for crashes are : checking for null value or empty string, passing invalid argument to API or complex multithreading interactions.
Steps to diagnose a crash.

A. Reading a Stack trace 

- use your logcat tool to read read the stack trace report
- stack trace has two important information: 1. type of exception thrown 2. section of code where exception is thrown

B. Reproducing a crash 

- Various enviromental context should be considered while producing a crash like : brandwidth, memory, storage
1. always use the emulator to create the device by managing the various settings of AVD manager: ex. controlling the memory
2. you can also use the emulator from command line by changing various parameters to reproduce the crash.
ex. emulator -avd [your-avd-image] -netdelay 20000 -netspeed gsm
to delay the network requests.

Comments

Popular Posts