HelloWorld Android App in 10 Steps

Finished product.

I was a little annoyed by the fact that the setup of a development environment and the creation of a simple app for the Android system was so spread out all over the place on Android’s developer website, so I decided to write up my own quick guide/tutorial/howto.

Don’t get me wrong, the developer website is great, I just wanted all the steps to installing the environment and creating an app in one place.

These instructions apply whether you’re using a Mac, PC, or Linux. All of the software below is cross-platform.

Please leave a comment if anything is unclear.

1)   If you don’t already have it, download/install JDK.

2)   Download and install Eclipse IDE for Java Developers (any package of Eclipse should be okay though; this particular one was the smallest download).

3)   Download and install the latest version of Android SDK.

4)   In Eclipse install the ADT plugin which connects the Eclipse IDE to all the Android SDK tools:

  1. Start Eclipse, then select Help > Install New Software….
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter “ADT Plugin” for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/
  4. Click OK
    Note: If you have trouble acquiring the plugin, try using “http” in the Location URL, instead of “https” (https is preferred for security reasons).
  5. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  6. In the next window, you’ll see a list of the tools to be downloaded. Click Next.
  7. Read and accept the license agreements, then click Finish.
    Note: If you get a security warning saying that the authenticity or validity of the software can’t be established, click OK.
  8. When the installation completes, restart Eclipse.

5)   Run Android SDK Manager, which you can now do in Eclipse, via Window (top menu) > Android SDK and AVD Manager. Make sure to download Tools, Platform-tools, and at least one Android Platform (e.g. Android 1.5 is what I will be using for this tutorial) under “Available packages.”

Note: If for some reason Eclipse can’t find the SDK location, you can set it via Window > Preferences > Android. There you can point Eclipse to your SDK installation path – e.g. “C:Program FilesAndroidandroid-sdk”.

6)   Create Android Virtual Device in “Virtual devices” by clicking on “New…” button. Give it any name you want, set the target to the platform you downloaded, and leave everything else as is. This will be the emulator your app runs on.

7)   Create a new project (File > New > Project…). Select Android Project. Name it “HelloWorld” and give it the package name “com.example.helloworld”. Any Android build target will work for this simple app.

8)   After the project is created, use the package explorer on the left (which you can enable via Window > Show View if it isn’t already) to expand your project, and open the HelloWorldActivity.java file in the src > com.example.helloworld directory. This is where your code will be.

9)   Replace the contents of the java file with the following:

package com.example.helloworld;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloWorldActivity extends Activity {
	/** Called when the activity is first created. */
	public void onCreate(Bundle savedInstanceState) {
		TextView tv = new TextView(this);
		tv.setText("Hello, Android");

As you can see there are only a few changes. You have imported a TextView widget class and used it to show a string of text.

10)  Finally, test the code by running it Run > Run, and select Android Application. The Android Virtual Device you created earlier in the SDK Manager should pop up, boot, and run your HelloWorld app. Congrats!

In my next post I’ll go a bit more into depth about application layout (buttons, text widgets) and actually having the app do something besides display text.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s