Saturday, December 22, 2012

[SOLVED] Unfortunately, Clock has stopped

This solution was published on the hajma blog. Pavel Heimlich deserves full credit here, but I am reposting it for convenience as it was an extremely simple fix for my Galaxy S2 running Cyanogenmod 10. Incidentally, the reason I had an error was that I lost my data connection due to some update and didn't have a recent backup, so I had to go back to a stock install of the OS. When I was restoring programs with Titanium Backup I noticed that, for some reason, Clock was not installed, so I installed it too. Then I got the above error. I use my phone as an alarm and really needed this back, hence the search for the procedure I've posted below.

When I upgraded my xperia ray from CM7 to CM9(FXP128), I was greeted by the message 'Unfortunately, Clock has stopped' whenever the phone started and anytime I touched the Clock widget. Apart from being annoying it meant I couldn't set my alarms so this became a priority one issue :-)

I opened the Terminal Emulator and typed:


$ su 
# logcat

Then I held 'Volume down' (a.k.a. Ctrl) and 'c' to stop the output. I scrolled a bit up in the output and found a line that said:

E/SQLiteOpenHelper( 5231): Couldn't open alarms.db for writing (will try read-only): E/SQLiteOpenHelper( 5231): android.database.sqlite.SQLiteException: Can't downgrade database from version 7 to 5

OK, so this is where it's breaking. I wasn't really interested in finding out what should the proper combination of ownership/permissions for the file as I didn't really trust it would end just here, downgrading database version offers a range of situations that can go wrong. And since I don't really care for my past alarm clock times, I got rid of the old database:

# cd /data/data/com.android.deskclock/databases 
# mv alarms.db alarms.db.bak 

Problem solved.


Thanks Pavel!