Android First Example: Hello World

Android First Example: Hello World


Android is a software stack for mobile devices that includes an operating system, middleware and key applications. 

The Android SDK contains API necessary to begin developing applications on the Android platform using the Java programming language.
In this article I point out the steps for making the hello world example and running it in the emulator.

The Steps:

In order to write the example follow these steps

  • The Android SDK

    • Extract it into your hard drive directory

  • Java Code

    • Make a new java project
    • set in the project class path android.jar (you can find it in sdk zip file)
    • make a new java class into
    • copy this source code in

//package name must be composed of at least two java identifiers

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

    public class Hello extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        //Make a new text view passing Activity object
        TextView tv = new TextView(this);
        //Set a text into view
        tv.setText("Hello World");
        //set the view into activity view container

    • compile code

  • Build and install The apps

    • In tools sdk directory you can find activitycreator.bat, launch it by passing the complete package name and class name:
activitycreator -o c:\android

    • The script prepare the android application putting it into c:\android directory

    • Now you need ant tools in order to build the android application
Download it from:

    • Go in c:\android directory
    • Launch: "ant -f build.xml" command
(note: if you go in "Unable to locate tools.jar" error you must set correctly jdk classpath.)
you'll be left with a file named Hello-debug.apk under the 'bin' directory

    • Go again in tools sdk directory.
Now you can use adb command in order to install the apk file into android emulator

    • First launch the emulator (if you don't adb command fails)
(note: in order to launch emulator you must execute the emulator.exe command in sdk tools directory.)

    • Then launch the follow command: adb install c:\android\bin\hello-debug.apk

  • Run The example

    • Close the emulator
    • Re-launch the emulator

    • Click on the arrow in the bottom of the screen so you open the application list, now you can 

    • find hello application.. click on it to see the hello word string..


It is only a small example introducing android development.
The next step is to go deep into

Please leave a feedback in the comment to this post.


Anonymous said...

Hi, we should do an android project. I'm still thinking my first real world application for a tutorial.

Anonymous said...

Documentazione in italiano:

Tseng said...

Nice guide for people who don't use eclipse. Updated my Post to link to this entry.

For people who are interested in another starters tutorial which goes bit further than "Hello World", check out my Blog post too

Giuseppe Morreale said...

You are welcome tseng. I see you blog, I find it very good!

jessica said...

Here is complete details for a starter from creating environment to writing an helloworld app

Anonymous said...
This comment has been removed by a blog administrator.