After building my Android SDK, it is now time to learn how to write applications. I have quite a bit of experience with Java, but there’s a bunch of Android-specific stuff to take care of. Unlike the Android SDK build I complained about, the documentation about application development is easy to find and comprehensive. I started with reading about “Application Fundamentals” and switched to the “Hello World” tutorial after the basics to get some hands-on practice before going into theoretical details.
I prefer to work with Emacs instead of using an IDE, so I set up the project as described here. Things mostly worked as expected, but I had to solve two small problems before the application would build successfully. I use the
$ ant install
target for building and testing. This should build the application, sign it with a debug key (only for testing, not release) and install it into a currently running emulator (exactly one emulator must be running for this to work). In the first try, I got this message:
For 'AOSP' SDK Preview, attribute minSdkVersion in AndroidManifest.xml must be 'AOSP'
Yes, my self-build SDK is an AOSP (“Android Open Source Preview”) and the solution was to add a
<uses-sdk> element to the manifest:
<uses-sdk android:minSdkVersion="AOSP" />
The second try failed as well, because for some reason the debug key was not created automatically (as the documentation says it should). So I had to create it by hand:
$ keytool -genkey -alias androiddebugkey -keyalg RSA -keystore ~/.android/debug.keystore -storepass android -validity 365
The next try failed with “
device not found,” but after rebooting the emulator (as suggested in the documentation), it worked. 🙂
As you can see, I added an input field to add text to the TextView. I really like the possibility to build the view structure through XML files, though I won’t put too much more effort into GUI stuff for now. What I need to write is a service.