Getting Started with Android Application Development

Introduction

In this article we will learn how to get started developing Android applications. We will walk through the steps to setup your environment and then create a sample application.

What do I need to get started

To develop Android applications, you need to install the Java Development Platform (JDK) and then install Eclipse, Android SDK and the Android Development tool plugin for Eclipse. All these tools are available for free.

Another option is to use Mono for Android: http://xamarin.com/monoforandroid

This tool allows you to use either the Visual Studio IDE or use the MonoDevelop IDE to create applications. It also facilitates installing the Android SDK. This is ideal for developers already in the .Net resource pool. They can leverage the familiar environment and tools to build Android apps thus shortening the learning curve. However, it also comes attached with a price tag. For pricing/licensing/additional info, you can reference the xamarin web site.

Since I have started looking into Android development at a hobbyist level, a good starting point for me was to leverage the free tools. I also wanted to figure out how different Android programming using the native tools was, through the eyes of a .Net developer.

So, here we go dipping into the Android waters :)

Step 1 : get the JDK - http://www.oracle.com/technetwork/java/javase/downloads/index.html and install it

Step 2 : get the Eclipse IDE - http://www.eclipse.org/downloads/

Step 3 : get the Android SDK starter package.

Step 4 : Install the Eclipse ADT plug-in: Within Eclipse, click Help -> Install New Software. Click "Add". In the Add Repository dialog box, enter "ADT plugin" for the Name and specify the Location URL: https://dl-ssl.google.com/android/eclipse/

If you get any errors after clicking OK, try using https in the above URL. I had some trouble at this point and kept getting an error message. Old friend google came up with several suggestions related to firewall issues etc. The solution was ultimately found on the Android developer site (http://developer.android.com/sdk/eclipse-adt.html#installing) to download the ADT plugin and save it locally (not unzip it) and then in the Add Site dialog, click Archive and select the downloaded archive. voila!

Step 5 : Install the Android platforms that you wish to develop against. Run the Android SDK and AVD manager and within the Available Packages menu select the platforms that you wish to download.

This is where I had hit a speed bump. I would get a connection error when the SDK and AVD manager tried to fetch the Available packages. I tried various options for firewall settings, http vs https setting as well as running the program as administrator. None of these solutions worked for me. Finally the step that I had to take as a workaround was to download the platforms directly and install the packages manually offline. Here is the best resource that I could find on getting this setup work.

Download Android SDK standalone for offline installation

http://qdevarena.blogspot.com/2010/05/download-android-sdk-standalone-for.html

Step 6 : Create a new Android virtual device - From the Android Virtual Device Manager (AVD). click the new button and select the configuration for the virtual device.

Let the coding begin

At this point I had a working environment and I hope some of the real life issue described above might help someone running into the same issues.

So we are at a stage when we can begin the coding. We start with a simple "Hello world" type program just to get the components running together to see how the end result looks like.

Start the Eclipse editor and select a default workspace. Click on File-New Android Project and enter the name for your project. I used the name "HelloWorld".


and01.jpg

Image: Create New Project

Next select the target platform. I have selected Android 2.2 for this example.

and02.jpg

Image: Select the platform

Next we provide the project configurations. Feel free to modify the settings as needed.

Add the code as follows within the java source file (HelloWorldActivity.java)

Source code

package com.android.HelloWorld01;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
 
public class HelloWorld01Activity extends Activity {
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         TextView tvHello = new TextView(this);
         tvHello.setText("Hello Android World");
         setContentView(tvHello);
    }
}

Now run the application.. If prompted, select to run the application as an Android app.

and03.jpg

Image: The application running in the emulator

Conclusion

We walked through the entire setup of development environment for Android applications. We also took a look at the practical issues that one might run into, through the setup steps. Finally, we stepped through a Hello World program sample. We can now explore the vast features available for custom app development on the android platform.

Happy Coding!

Up Next
    Ebook Download
    View all
    Learn
    View all