skip to main bit
a man slumped on his desk, from 'The Sleep of Reason Produces



actual android hacking

Just to show that “disappointing” in my previous posts isn’t some euphemism for “die, impure heathens!”, I’ve been continuing to hack on my G1. Honestly, even if it is an impure love, I’m loving both the phone itself and the application environment. Its integration with the Eclipse IDE even managed to draw me away from Vim. You see how its corruption burns into my soul?

Anyway, for your delectation for Hello, World style programming, and also because Liz wanted it, here’s an Android application I threw together that displays an arrow that (should) always point north (it’s not very accurate, but what do you expect from a $200 compass?) (Source etc for Android Compass.)

Things I like about the SDK: it’s well-documented, and when it isn’t, you have all the source to read. I can’t overemphasise how much of a relief this is. I haven’t coded in Java in literally decades, but with enough code examples I got into the swing (ha, ancient java funny) of it fairly quickly, and also I suspect picked up bits of the Android house style.

The community is a little big fractured — I sense there was a lot of early excitement when the first SDK came out, but a lot of those developers wandered off leaving too many ghost sites). Still, there is now a lot of Android hacking going on in public, and the IRC channel remains very informative (when I wandered off into implementing something with SurfaceView instead of just plain View and then wondered why my onDraw method didn’t work, they quickly put me to rights: you don’t use onDraw with SurfaceView, and you probably don’t need SurfaceView to begin with.)

The tools to interact with the phone seem very mature to my have-not-worked-with-embedded-systems-for-a-decade eyes. I found logs where I wanted to find them (in the IDE, and by typing adb logcat). I didn’t get the sense that Linux was a stepsister to the Windows and MacOS dev environment (and I hope that they do okay by comparison also). The emulator is a godsend, and well-integrated: when I didn’t have the phone plugged in, my code ran in the emulator. When I did, it ran on my phone. Things worked first time. I had fun, and had something to show off on my phone in an evening.

(Two gotchas that I hit when trying to produce this blog entry. I installed the java6-sun packages to run Eclipse and the SDK tools, but you have to actually select it to run rather than the openjdk on my Intrepid Ubuntu setup. Use sudo update-alternatives --config java to pick between the two. Eclipse actually ran fine under the openjdk, but Android’s ddms program complained a little about a GNOME Accessibility Bridge until I switched.

If you don’t want to use Sun’s Java, commenting out the single line assistive_technologies=org.GNOME.Accessibility.JavaBridge in /etc/java-6-openjdk/ also lets you run ddms.

And when you’re signing your Android package (using these Germanic instructions), it turns out that you should sign the apk file in your bin directory, not the one that Eclipse handily offers to export for you. Thanks to toediggety for that obscure bug. You see? Fun!

2 Responses to “actual android hacking”

  1. Jesse Says:

    Indeed, I’m having more fun relearning Java than I ever expected I would. It helps that they let me fork their mail client and republish it on the market ;)

    So, um, where’s the IRC channel?

  2. Danny O'Brien Says:

    #android on — it’s fun spotting the Google developers…


petit disclaimer:
My employer has enough opinions of its own, without having to have mine too.