Home‎ > ‎Software Projects‎ > ‎

Android - "Hello World"

Just start here http://developer.android.com/sdk and follow the Quick Start Guide provided. It is really amazingly easy. But in case you need even an easier guide than the one provided I have made notes of my specific steps here in one place. Hopefully you already have Eclipse installed (Galileo). If not...well then really, what were you thinking?
The following basically walks you through installing the Android SDK, ADT and writing, compiling, running and debugging the "Hello World" application all on one page. If you want to skip all this and just see what the application does, then simply download the Hello Android application I compiled and built. You can run this application on your own device or in the emulator.
Android SDK (Software Development Kit)
The first thing you need is the Android SDK. The instructions on the Quick State Guide state "Select a starter package from the table at the top of this page and download it to your development computer. To install the SDK, simply unpack the starter package to a safe location and then add the location to your PATH. " I wasn't sure exactly what "safe location" meant, but apparently in the eclipse source directory is just fine. So for my platform I simply expanded to C:\Program Files\eclipse\android-sdk-windows
So, download and Un-Zip the Android SDK to C:\Program Files\eclipse\android-sdk-windows
Android ADT (Android Development Tools)
Install the Android ADT using the provided instructions.
  1. Start Eclipse, then select Help > Install New Software.
  2. In the Available Software dialog, click Add....
  3. In the Add Site dialog that appears, enter a name for the remote site (for example, "Android Plug-in") in the "Name" field.

    In the "Location" field, enter this URL:


    Note: If you have trouble acquiring the plug-in, you can try using "http" in the URL, instead of "https" (https is preferred for security reasons).

    Click OK.

  4. Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the check box next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
  5. In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish. Note: You may get a security warning which says "blah, blah, blah..." we never read those things anyway...so just say OK.
  6. Restart Eclipse.
First Time "Post Android Install" Eclipse Start-up
Now, hopefully Eclipse starts up again (whew!). Now when it comes back up there will be a noticeable change to your tool bar. It will now contain the awesome "Android SDK and AVD Manager" as shown on the left.
Now before you get all nutty and start writing code; you need to change the Android preferences. Select Window -> Preferences -> Android. In the Android window and at the SDK Location Field enter C:\Program Files\eclipse\android-sdk-windows or wherever you put the SDK. Select OK. Let it configure and set-up the Android SDK for you.
Now, launch the Android SDK and AVD Manager by clicking on that "Android Device" icon. Select Available Packages and expand the Android Repository. Now you need to choose one or more Android API Levels you might need (See API Levels).  The API Levels refer to a specific version of the Android API your going to use. If you are not sure just pick the highest one (currently API Level 7 - Android 2.1). You can also choose to include Google APIs which allow you access to maps and other Google, Inc. type things. Only choose the documentation for the API Level you choose if you think you need off-line documentation, otherwise why take up the space on your hard drive as all APIs are easily accessible via the web. If you decide later you want to have one or more API Levels that you didn't have the foresight at this time to install no worries. You can always go back and install others later.
Select Install Selected and when prompted select Accept All and then Install Accepted to accept all the various packages automatically. Now be patient as it installs the selected SDKs. This may take a while so go get some coffee, juice, jolt or whatever you need. Or simply just go do something useful with your life while it installs.
When the installation is complete it may prompt you to perform an "ADB Restart" go ahead and say OK.
Create an Android Virtual Device (AVD)
After the ADB has restarted go back to the Android SDK and AVD Manager box and select Virtual Devices and then select the New... button on the right. You will need at least one AVD to create any applications. There are various device options you can select for your AVD based on your needs but even the simplest AVD will get you started. Here are the options I used to emulate a Motorola Droid.
First, give your AVD a name, like "MyAndroid"
Motorola Droid-ish AVD:
  • Target: Android 2.0 - API Level 5
  • SD-Card Size: 512 MB
  • Skin: Built-In WVGA854
Now just select Create AVD and when that finishes close the Android SDK and AVD Manager box.
Note: After making your AVD, you need to wait a strangely large amount of time, but don't panic, all is well. What that finishes you are ready to create a project, write code, compile and run it.
Start the "MyAndroid AVD"
At this point in the tutorial you are typically sent off to go write the "Hello World" application. But instead of doing that I think it is a bit more fun to just go ahead and run your AVD so you can see what an AVD actually looks and feels like.
To do this simply select the AVD you just created in the Android SDK and AVD Manager box. Now select the Start... button. You will be presented now with the AVD Launch Options dialog box. Just select the Launch button.
At this point it will start the Android Emulator which may take a while. It always takes a seemingly very long time the first time one is started. After that it appears to come up pretty quickly. What is happening here is the emulator is booting just like a real device would, but as a window on your desktop. As it is booting you will see the ANDROID logo text. Just be patient, it will come up eventually. It is not unusual for this to take a few minutes.
Here are the 3 boot stages your likely to see...
Boot Stage #1
Boot Stage #2
Almost there!
Boot Stage #3
Full UI ready!
 What is super cool about being able to run the AVD like this is that you can easily play with the UI, install and run applications and basically use the virtual device as if you had a physical one in front of you. I mean you can't make an actual phone call or anything (ah! but you can actually...sort of...really just try it) But the ideas is that almost everything else works just like it would if you got a new device. You can browse contacts, look at maps, browse the net, etc. Ok...so enough fun, now it's time to do a little work.
Create the Android "Hello World" Project
 Now your ready to create the project using Eclipse. the next step is to start a new Android project in Eclipse. For this it's just like the  Hello World page, not much to add here.
  1. From Eclipse, select File > New > Project.
  2. Select "Android Project" and click Next
  3. Fill in the project details with the following values:
    • Project name: HelloAndroid
      • This name of the directory that will contain the project files.
    • Application name: Hello, Android
      • This is the application title which will appear under the icon on your device.
    • Package name: com.example.helloandroid (or your own private namespace)
      • Note: Your package name must be unique across all packages installed on the Android system
    • Create Activity: HelloAndroid
      • This is the name for the class stub that will be generated by the plugin and will be a subclass of Android's Activity class.
    • Min SDK Version: 5
      • This value specifies the minimum API Level required by your application. Android applications are forward-compatible.
  4. Click Finish.
Anyway, you can follow that page just like anyone else. But if you want to skip to the meat and just Import the project you can download this project archive and import it into Eclipse. Just build and go. This project includes the suggested upgrade of the UI to an XML layout.
Import the Project
Download and import the provided project into your Eclipse workspace:
  1. Select File > Import... > General > Existing Projects Into Workspace.
  2. Select Archive File and put in the filename and path (e.g. X:\Projects\Android\HelloAndroid.zip).
  3. Select Finish
  4. Rebuild the Application (CTRL+B)
Run the Application
The Eclipse plugin makes it very easy to run your applications:
  1. Select Run > Run.
  2. Select "Android Application". 

At this point the Android Emulator will appear, boot and come to the start-up screen. Unlock the Android device and you will see that you application is running.

The guide suggests that you read Application Fundamentals for an introduction to all the elements that make Android applications work. Also refer to the Developer's Guide introduction page for an overview of the Dev Guide documentation. This is probably a good idea at this point.