June 29, 2010 by

I have often found that Google’s quick start guide for Android development lacks crucial details. Finally, I decided to do something about it. This tutorial should help an absolute new comer to Android programming.

Before you start, make sure that you have these installed:

  • JDK 6. Just JRE is not enough. You will need to install full JDK.
  • Eclipse Galileo

Install Android 2.2 Platform

Download android SDK 2.2 from this link. Unzip the ZIP file under C:\. This should create the C:\android-sdk-windows folder.

Add C:\android-sdk-windows to the PATH environment variable.

Log off and log back in for the change to PATH to take effect.

Now, we will download the Android 2.2 platform.

From the C:\android-sdk-windows\tools folder, run android.bat.

image

Select Settings on the left hand list.

Check the Force https checkbox as shown above.

image

Select Available Packages.

On the right hand side, select SDK Platform Android 2.2, API 8, revision 1 as shown above.

Click Install Selected to start installation.

image

Click Install.

image

When installation finishes, click on Close.

Install Eclipse Plugin

Make sure that you have added the SDK directory to PATH environment variable.

Launch Eclipse.

Select Help > Install New Software.

Click the Add button to add a new site.

image

Add the https://dl-ssl.google.com/android/eclipse/ URL as the new site. Click OK.

image

Expand Developer Tools and check Android Development Tools.

Click Next.

image

Click Finish.

image

Click OK.

image

Click Yes to restart Eclipse.

Create a Virtual Device

An Android Virtual Device (AVD) is a device (phone) emulator. You will use it to test and debug applications.

From Eclipse menubar, select Window > Preferences.

image

Select Android.

Click Browse button and select the directory where the SDK was installed (C:\android-sdk_r06-windows in our case).

Click OK.

From menubar, select Window > Android SDK and AVD Manager.

Select Virtual Devices on the left.

Click New.

image

Enter my_avd as the name. Select Android 2.2 as the target.

Click Create AVD.

Close the AVD manager.

Write a Simple Application

We will now develop a basic application to test our development environment.

in Eclipse, select File > New > Project from the menubar.

image

Expand Android and select Android Project.

Enter the values as shown below.

image

Click Finish.

Expand the HelloWorld project and then src > com.webage.hello.

image

Open HelloActivity.java.

Change the onCreate method as follows.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView tv = new TextView(this);
    tv.setText("Hello World!");
    setContentView(tv);
}

Organize imports (Control+Shift+O).

Save changes.

Test the Application

While the editor for HelloActivity.java is active, from the menubar, select Run > Run.

image

Select Android Application. Then click OK.

System will start the Android Virtual Device. This can take up to 5 minutes. While the device is booting, the screen will look like this.

image

Then, you will see the home screen.

image

Finally, the application will be started.

image

To exit the application, click the home button.

image

Congratulations, you have successfully installed the Android development environment and tested your first Android application.

3 Comments

Rick Kawala

So first we install the Android SDK 2.2, which is a 75 MB download. Then we start the “SDK and AVD manager”, go to Available Packages and select the 2.2 SDK again. Haven’t we installed the 2.2 SDK twice?

Thanks for doing this tutorial, by the way!

Reply
Rick Kawala

I think I figured it out. When we download http://developer.android.com/sdk/index.html what we get is not the SDK. We get a “tools” directory and the SDK/AVD manager. Then you run the SDK/AVD manager and use it to download the real SDK.

Instead of saying “Download the SDK from this link” you might say “Download the SDK manager from this link.” That would’ve made it clearer, I think.

Reply
Bibhas Bhattacharya

Hi Rick, what you download the second time is the “SDK Platform”. The platform includes the runtime and JAR file for a specific version of Android.

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *