Recovering ASUS Zenfone from bizarre app crashes

TL;DR? Scroll to the “Summary” below.

A few weeks ago, my ASUS Zenfone 2 (ZE551ML) started experiencing bizarre crashes. At first only the ASUS Browser app was affected. The symptom was the standard “Unfortunately, Browser has stopped” message, after which the browser would crash with the same message every time I tried restarting it. “Force stop” and clearing cache did not help, but rebooting the phone did, and everything continued working normally for a while.

Eventually, the problem became more frequent and became worse – now after reboot other key apps started crashing in the same manner – the Launcher, which made home screen inaccessible (although app notifications and recent screens worked fine), and sometimes System UI itself (at which point nothing worked except holding down the power button to shutdown/reboot the phone again). Usually after a few reboots things would work OK, sometimes just waiting for 5, 10, 15 minutes after boot would get things to start working, but in a matter of a few hours, tops, the issues returned.

zenfone2The standard solutions (clearing cache of individual apps or wiping the cache partition through recovery mode) did not help. The interesting thing is that no apps but those three (Browser, Launcher, System UI) ever crashed. Out of curiosity, I connected the phone in USB debug mode to the PC, and viewed the system log in Android Studio. The errors coming from the three apps were very similar – FATAL EXCEPTION: main (which triggers the hard crash), referring to some android.view.InflateException in some Binary XML, with the actual error being “Error inflating class”. The line number and class name would change sometimes, but the pattern was always the same.

Searching online shows that such errors are typically encountered by developers (although it’s an obvious search bias, since non-developers are far less likely to look at debug logs), and usually indicate some bugs in their own application. I was stumped as I was getting the errors from core system applications, most of which have stopped receiving updates a while ago, and worked perfectly until recently. Just in case, I did try rolling back whatever I could to the factory versions, but that didn’t help either (neither did reinstalling the latest updates). Finally, I broke down, backed up the phone and did a factory reset. No dice. First boot – same problem (first Launcher gives up, then System UI).

Then it dawned on me (and I wish it happened earlier) – a factory reset only wipes the user partition, not the system one. The core apps however reside on the system partition. What if something got corrupted there? With that idea I proceeded to do the natural thing – downloaded the latest Zenfone 2 System Image (same one I already had installed), and reinstalled it to the phone using adb sideload. Voila! All problems gone. It’s been a week so far, and not a single crash.

The best thing about this solution is that – as long as you are reflashing the same firmware version that’s installed – no settings are altered and no user data is lost. So in retrospective, I would not have had to wipe and start over, but in the end, doing a clean start (which I last did more than a year and a half ago) felt good, allowed me to purge some junk, and somehow it even feels that the battery lasts a bit longer too (which is a weak spot of this model).

One last thing: a common problem when backing up pictures from the phone to the PC and then copying them back to the restored phone is that the sorting order gets messed up. This is because when the files are recreated on the phone, the original timestamp is lost (gets replaced with the current time). This is a known long-standing bug in Android, which Google only fixed in Android 8 (unfortunately, the Zenfone 2 only goes up to Android 6), and there is no sane way of changing it on an un-rooted phone. In principle, I could have gone the root way, but another way felt easier: the ASUS Gallery, which is the default image manager for the phone, and one I quite like, uses the EXIF tag metadata to sort, before the file date. All the photos taken by the phone automatically get an EXIF tag with “date taken” attached, so there is no problem there. For other images, I used EXIF Date Changer on the PC to create a “date taken” entry based on the filename or the timestamp (the timestamps are correctly maintained in the Phone→PC direction; only the other direction is messed up). I am not sure how it would work for videos (as they store the tag differently), but I am sure there must be a solution for those as well.

Summary

  1. If your Android-based smartphone starts getting inexplicable crashes in built-in system apps (“App X has stopped working”), and if these crashes persist after restarting the phone, uninstalling/reinstalling all app updates, force-stopping the app, clearing app cache, clearing app data, and even wiping cache partition, then it is possible that some of the data on the system partition is corrupted.
  2. A factory reset (wiping user data and settings) usually will not affect any data on the system partition, so this step may not help. Instead, you should try reloading the system firmware image (either through the phone UI if that still works, or through SDCard/ADB in recovery mode). The instructions on how to do it are specific to each phone. If you reload the same firmware version that is currently on the phone, there is a good chance no settings or user data will be affected.
  3. If date-based image sorting breaks after you back up images from the phone to the PC and restore them back to the phone, then it is probably due to the Android bug which prevents altering timestamps on non-rooted phones (only fixed in Android 8.0). Although most images gallery apps use EXIF tags to sort images by date, not all images have such tags by default.
  4. If your images lack EXIF tags, you can use a tool such as EXIF Date Changer to add a tag with “date taken” to the images on your PC and then copy the tagged images back to the phone. The tags can be generated automatically from timestamps or filenames, and this process does not alter the image itself and does not affect its quality.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s