otak info official Logo   
Personal Blog

Hariyanto Lim

정길상 / 鄭吉祥
Home   Last Posts  
Please login to see more topics and discussion categories.
goto main category list >> Software programming >> Android

Title : How to simulate Android OS kill our app
Total Reply : 0
Total View : 2634

Total thread: 131
Total reply: 50

Post #171
How to simulate Android OS kill our app
I have made a few large Android apps, by "large" I meant a quite complex UI with severals activity and using some ViewPagers.

There is one problem/issue that is hard to detect is that our app crash when Android OS kill our app then user click our app icon to restart our app, normally the problem was NullPointerException or ArrayIndexOutOfBoundsException due to some Singleton class or static variable object has been cleared by OS and did not restore.

Normally we found the issue after we put our app idle in the background then we dont use it for a few hours, then when we restart the app, it is crashed immediately on re-opening, Fabric Crashlytics does not help much, we could not afford to put so many Null check and other traps or simply put a lot of logs inside app for release version.

I and my team members know about the problem, it is because the OS kill our app but we could not pin point the exact position of the crash because the crash occurred in multiple places which seem like a random location.

We normally trying to find it by running the app UP TO the screen where the crash happend then we press HOME key to put our app running in the background then we start other large apps to consume the memory and keep doing it until OS kill our app and we can restart the app to see the crash log, this task is very time consuming and not efficient.

Today, when I encountered the same problem in my newest app (info.otak.HAndBible), I could not resist it but to keep searching for clue about how to solve this issue in a more efficient manner, then fortunately I came across this discussion : http://stackoverflow.com/questions/11365301/how-to-simulate-android-killing-my-process, which someone with user id "HexAndBugs" said about using '
', ' ', 'adb shell am kill <package name>').'
' is different with '
', ' ', 'adb shell kill').'

With this new useful way to simulate OS kill our Android app, it makes my work so much easier to hunt for bug by simply open my app and put it in the exact condition where I want to test for error then click HOME key to make it go to background then I execute "adb shell am kill info.otak.HAndBible" to see (in LOGCAT) my app dead immediately then immediately restart the app to see the problem.
Falling in love with the world

Write : 2016-03-24 14:17:46

If you want to create a new reply then please login first.

Since 19 January 2007
Page hit : 1,016,638

Code update 24th June 2013
Brain is a very capable to solve big problems
but requires constant reminders about how to.
peace bird