Wednesday, March 11, 2009

Life of an Android app

After getting an Android dev phone, I was tempted to write my own app for it. Since I am the proud father of 3 girls now, I wanted to do something that they can play with: an app with which they can color an image with their fingers. Now, after about 2 weeks of development time everyone can download it from the Android market by the name "Zebra Paint".

The start was easy - even though I have never used Eclipse before, the instructions for setting up the emulator and the environment were crystal clear. Doing Hello was also a piece of cake, less than 30 minutes. Choosing a new Android project adds everything needed and the logic is about 2 lines of Java code. Even better, it keeps everything up to date during development, e.g. when one adds new resources, the pointers from the code are automatically updates. XML files containing resources are also checked on the fly. When a line is changed I can see immediately if it works or I have made a mistake. That adds a quite rapid feel for development.

Not everything is easy, though. Understanding the fundamental concepts like resources and activities needed some time. Probably the worst thing is that while there is Javadoc for everything, the documentation describing resources lacks details and examples in many places. For example there are "drawables" that can be used to paint just like anything, there is no reference docs, no tutorials. The examples cover some simple cases but I have the feeling that drawables are capable of much more than what's documented. For instance, layers and combining objects.

The other surprising thing was that the Dalvik VM is actually slow and nowhere near the speed that I predicted based on that the CPU is more than 2x faster than my Symbian E61. For a simple algorithm like flood fill a lot of int array magic and ugly design was necessary because the VM could not get through it.

Overall, doing it was faster than on Symbian, but there is room for improvement. Hope you enjoy Zebra Paint!

No comments: