The number of apps in the Android market has been growing at a breakneck speed and soon looks to surpass 100,000, giving the iPhone app store a run for its money. The developer community has been showing some serious interest in developing apps for Android as well as contributing to the OS codebase. The lower entry fees (25$) as compared to the iPhone ($99), combined with the more liberal acceptance criteria has done much to fuel interest.

There are two kinds of contributions that interested developers can make to the Android platform. First is testing out and submitting patches to the Android codebase and the other is to write applications targeting the platform. The applications are to be written in Java which simplifies the development process by quite a bit. I wrote this post to show how to set up the Android development environment to write apps.

Before starting development, there are a few points every new mobile app developer should keep in mind. Though not an exhaustive list, it serves as a reminder of few crucial points.

The Java code that you write isnt compiled by the usual JVM but a lighter implementation called Dalvik. So a lot of compiler/runtime optimizations are unavailable to us yet. Just in Time Compilation has just been added in Froyo. Other optimizations like Method inlining, caching are not added so use direct fields where possible rather than properties.

Responsiveness is of paramount importance in a mobile OS. On a PC, people might not notice lags of a second or so, but on a handheld device, even the smallest of lags is instantly noticeable and decreases the user experience

Don’t take device display for granted. Android has been used on devices with varying display sizes – from phones to netbooks to tablet pcs. So while coding the layout, keep the appplication as end device agnostic as possible.

To get started, we need the following components.

Eclipse IDE (both Windows and Linux)

ADT plugin for Eclipse

Google SDK

Android platform components.

First the Eclipse IDE. This by the way, is the only step that would differ between Windows and Linux. All others are pretty much the same.

On Windows, the IDE can be downloaded from the site – http://www.eclipse.org/downloads/ and run the setup to install. Linux’s package manager makes the install a simple one step process. In the command line type

sudo apt-get install eclipse

sudo apt-get install eclipse

Next, download the Google Android SDK from this page as per your platform. The MD5 checksums for the archive are given, so you can verify the integrity of the file after download. Expand the archive to the disk. Now we need to install the ADT plugin for Eclipse. To do that go to Help -> Install New Software. Here the site of the ADT plugin needs to be added – https://dl-ssl.google.com/android/eclipse/. Once that is done click Add, and choose bothÂ Android DDMS and Development tools and click Finish to install them

Now open Eclipse and choose Window -> Preferences -> Android. In the Options page, give the path of the folder where you stored the SDK.

Once that is done, we need to download the SDK components. These components differ for each API version. The higher the version goes, the more features you will get. But the number of devices your application will support would also decrease. So its always better to target the most stable current release which would be on a majority of devices. Go to Window ->Android SDK and AVD manager. In the Virtual Devices tab click Add and create a new Android Virtual Device. This is the emulator that we can use to test our applications on. Enter the required details and remember to set the memory card size above 10 MB. Once you Create the AVD, it will show up in the Virtual devices tab.

Then, select the Available packages tab in the same window and click on the plus sign next to the web address. This will give us the available packages which can be installed. Choose any one of your choice and click Install Selected.

Once the SDK is installed you will be able to create Android applicatons by Going to File -> New -> Project -> Android Project. In my next post I will explain how to write a simple Android application.