Sunday, June 3, 2012

Android Development

I have recently started developing a new application for the Android platform. It had been a while since I experimented with Android and this really manifested itself when I started this new project a couple of months ago. Having to deal with new Android features and corresponding backwards compatibility issues, I experienced a steep learning curve. This article highlights the lessons learned during this process.

JDK Selection

I have been a Linux user since 2001 and never looked back since then. So if you are developing on Linux, make sure to replace the default OpenJDK with Oracle's. This will save you a lot of headache dealing with peculiar errors and exceptions during the initial set-up process.

Selecting an IDE

I really like NetBeans and still develop with this IDE when it comes to PHP; it definitely feels much more intuitive than Eclipse. However, when it comes to Android development, it did not take long for me to realize I was fighting an uphill battle. With its excellent Android Development Tools (ADT) plugin integration, Eclipse definitely shines when it comes to programming for Android. In my case, the process of switching from NetBeans to Eclipse definitely took its toll both in terms of learning curve and time spent for customization to get Eclipse to a usable state.

Android API Levels

What API level to support? Well, the answer is not hard to find. On the official Android site, you can find the current statistics for platform versions. To penetrate the majority of the Android market, you need to support API Level 7; however, your application should also perform on the newest handsets running the latest version of the Android SDK at API Level 15. This is accomplished by adding the following line to your AndroidManifest.xml:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />

This simply means that when writing your code, you need to be careful in order to maintain backwards compatibility with API Level 7. This is pretty easy to accomplish thanks to Android Lint but what about forward compatibility? How do you utilize the newest features?

Supporting Libraries

New functionality introduced by the latest Android SDK will obviously not be available in older versions. This means that you will have to get comfortable utilizing the support libraries. One of these libraries is the Android Support Package that allows you to utilize certain new features such as fragments.

However, not all new functionality is supported by the Android Support Package. To get action bar support, you will need to download the ActionBarSherlock library.

These extra libraries do make the learning curve a little bit steeper but they are essential tools needed to create a Android application these days. Unfortunately, they are not silver bullets. There are still issues that need to be addressed; one of which manifests itself when you need to embed a MapView inside a fragment.

Other Libraries

If you are planning to integrate your Android application with REST services over OAuth2 , have a look at Spring for Android. In addition, you may be interested in SLF4J Android for your logging needs.

Thoughts on Android

Android reminds me of the early Linux days. The platform still has its fair share of problems but it is an open platform that is improving and maturing constantly with every release. Considering I flashed the one and only Apple product - a 5th generation IPod that was given to me as a birthday present years ago - with Rockbox the next day I received it, it is not surprising to me why I am interested in this platform. Besides, now that Android is slowly being merged into the Linux kernel, do I have a choice?

No comments:

Post a Comment