I had noted before that my accelerometer had broken on my Android g1 phone, so that one axis was out by about 40 degrees. Despite lots of “helpful” suggestions from my friends on how to fix it (you know who you are), nothing worked. This did.
Connect to the phone with adb (from the Android SDK), in the following way.
./adb start-server ./adb shell # cd /data/misc/ # mv amkd_set.txt amkd_old.txt # killall amkd
Now it works.