Android Development

A patch I wrote for mobileorg-android was accepted and shipped to the Market in mobileorg-android 0.4.8. It works around lighttpd’s missing support for the Expect HTTP header. The issue was that pulling from lighttpd to the phone would work, but pushing from the phone to lighttpd wouldn’t.

To debug the problem I set up an Android development environment. In doing so I found android-mode.el and android.el (shipped with the SDK in android-sdk-linux_86/tools/lib) very useful both during development and initially for learning the Android Emacs workflow. For the most part, developing for my Nexus One was very straightforward. The only issue I ran into was not being able to start /sbin/adbd on the phone.

Since none of the Android development tutorials I Googled mentioned this problem, I’ll outline the symptoms here. If this issue affects you, the Settings -> Applications -> Development -> USB debugging check box on your phone will have no effect. After you’ve checked “USB debugging”, when you plug your phone into your development machine via USB, the USB file storage dialog will come up. “adb devices” on your development machine will not list the USB-connected phone. If you open a terminal window on your phone,

$ getprop persist.service.adb.enable

will print 0, and

$ ps

will not list /sbin/adbd.

When things are working correctly, checking USB debugging causes /sbin/adbd to be run on the phone. /sbin/adbd exports different USB endpoints to “adb fork-server server” (started by adb on the development machine) so that the phone shows up as an Android development device, instead of a USB hard drive.

In my case the workaround was to check “USB debugging” then reboot my phone. After the reboot, persist.service.adb.enable was set to 1 and /sbin/adbd started when I checked USB debugging.

Unfortunately I couldn’t find a way out of this scenario without rebooting my phone which I avoid doing if possible (my best uptime so far is 60 days ended by the 2.2.1 system update). I haven’t rooted my Nexus One so /sbin/adbd caused “Permission denied”, and I couldn’t change persist.service.adb.enable to 1 with setprop; it would stay set to 0. Without /sbin/adbd (and before I discovered the reboot workaround), I was left having to manually install a mobileorg-android .apk file via the SD card which was a pain. I was disappointed that I didn’t have control over persist.service.adb.enable (which I assume I would if I had root). The main reason I bought the Nexus One was for its unlocked hackability, so things like this leave a bad taste. Hopefully the issue I linked to gets resolved.