[This is part of the Android Diary.] As of late last night, I have a bit of nontrivial code actually running on the G1. I feel a bit reluctant to diarize since I’m a complete beginner, swimming in ignorance; but it occurs to me that for every expert out there, there are many n00bs like me, who might wonder what the experience is like.
How to Learn · Just like everyone else, I started with the Hello, Android! tutorial. There is a ton of material here and there around the net. As of now, here are the browser tabs I have open (the order is not significant):
Diego Torres Milano’s Blog: good discussion of unit testing.
Troubleshooting page at the Android googlecode site.
Android Debug Bridge (adb) reference.
How to Program Google Android by Reto Meier. [Article updated to reflect API changes.]
Actual Android Hacking at Oblomovka.
The local copy of the Android JavaDocs, which came down with the SDK.
A post I dug up from the Android Developers group via Web search (more on this later).
Tools · I’m using the Android plug-in for Eclipse. Yes, I’m a NetBeans partisan, professionally and personally, but I’m also hardly unusual in using both. It just seemed that all the demos and troubleshooting and walk-throughs assumed you were on Eclipse. Also, I hadn’t hand my hands on it for a while, so I was curious.
For someone who’s used to NetBeans, the transition is effortless. Eclipse on the Mac doesn’t look nearly as pretty, but most of the stuff I’m used to is easy to find. And the integration with the emulator and device is pretty slick.
Having said that, I suspect I’ll be leaving Eclipse behind. I get the feeling that the serious developers are mostly using the raw tools from the command-line, and that Eclipse will start to feel like training wheels pretty soon. Also I hear some rumbles about IntelliJ.
Problem: Unit Testing · This is a really big fucking hairy problem. So far, the large majority of my code does mundane things like HTTP-fetch chunks of XML, parse the XML, and pull together iterators of one flavor or another.
I’m pretty TDD-infected, and I just don’t feel comfy writing any volume of code without hitting the “run the tests” button. Android just doesn’t make this easy or obvious. There are work-arounds out there: see Diego Torres Milano here and here; also at Google Code and Google Groups.
I can’t report on any of these workarounds first-hand. What I did so far was sketch in all the code in an ordinary Eclipse project with ordinary JUnit tests, then drop it into the Android project once it was working.
Which constitutes major suckage.
Problem: Trouble-shooting ·
When I took my apparently-running code and dropped it onto
the Android emulator, it blew up with a “SocketException - unknown error” the
first time I did an HTTP GET via Apache’s
stack trace sprawling unhelpfully all over the Android runtime.
Fifteen seconds of Web search turned up the solution; but still, it would be nice if the system had something useful to say about why it wouldn’t GET.
Problem: Over-eagerness · This is a little weird. I got my code running in the emulator well enough to display a line or two of read-out (no graphics yet), so I went and got the G1 and plugged the USB link into the computer. Then I started casting about to figure out how to install and run the app. While I was doing this, my eye happened to fall on the phone and what do you know, there was my app running.
For the moment I was all “W00t cowabunga, I’m a certified 133t mobile haxx0r!” Then I thought “Danger, Will Robinson!” Suppose that’d been the ClearContactsListAndSync app or the LaunchNuclearFirstStrike app? So what Eclipse really needs is a nice prominently-featured “Upload to phone and run” button or some such. Did I mention training wheels?
Next Steps · Well, one o’ them there Graphical User Interfaces the kids these days seem so hot on. Plus some more network pipefitting. Then some decision points about whether I care about the result, and whether anyone else might, and whether Sun should.
But, it’s still a milestone; the first time I’ve seen my code running on a device I can carry in my pocket.