Last week my wife gifted me a new mobile wishing not to miss her calls anymore. My (very very) old mobile celebrated its 7th birthday and I decided to allow it to RIP. For one reason, I held on to it for these many years. It simply did what its supposed to do, making/receiving calls and occasional use of sms. 
But, the new mobile in my hand is completely overloaded and I feel like Bond. It has touch, a full fledged slider qwerty, proximity sensor, accelerometer, GPS and rocket launcher. Yeah yeah I can hear you, nowadays even the most basic model has all these.
I connected it to my home wifi network and went to the roof of my apartment. Just to see how well it picks up the signal. A neighboring kid was curiously looking at me. I thought, he was going to ask me is that a video game console? He is just in his fourth grade. Believe me he asked, ‘uncle, is that an android?’
Android fever is really catching up. If you don’t murmur about android, people won’t believe you as a technologist. If you are a software developer you should at least write a “Hello World!” in android. That’s what we are going to do in this article. We know how android gets related to java and so to a java blog. Oops! I am not mentioning about the Oracle’s case against Google claiming the presence of java code in android.
As always, Hello World is the easiest step you can keep forward in learning a language. I would say, writing Hello World is not about learning the language. It is all about learning the setting up of the development environment, how to compile, interpret / execute.
IDE is everything in Hello, World
If you have completed setting up the development environment, then Android’s Hello World is simple. If you are using Eclipse as your IDE, settingup it for Android is also simple. Its about just installing a plugin. If you are not using Eclipse, don’t worry there are nice documentation available in android’s site.
Hello World requires the following steps
- JDK 5 or above (JRE alone is not sufficient) installation
- Eclipse Ganymede or above installation
- Android SDK Installation
- Android Development Tools plugin installation
- Android Emulator – Android Virtual Device (AVD) Creation
- New Android Project Creation
- Create Hello World Android source
- Run Hello World
A word of caution. If you are going to do this Hello World Android from your office computer, get necessary permissions from your manager. Since, you may be behind some proxy/firewall the software update sites might be blocked. You may get frustrated setting up the IDE.
If you are a java guy, you should be already having some JDK installed in your computer. Just check the version for compatibility. If you have a older version of Eclipse, download the latest version. No harm in having multiple Eclipse versions. Android SDK and plugin installation, just follow the instructions given the URL I have given above. They are more than sufficient.
After you install the ADT plugin, restart the eclipse. Then in Eclipse, Window -> Preferences (in left panel select Android) then give your SDK installed location in the right side panel.
Android Emulator
If you have an android mobile and you want to execute your Hello World in that, there is a time for it. First master yourselves with the basics and you can use the Android Emulator. Always try first with the emulator before going to the real mobile. It will save you lot of time. 
Click the android icon (with a white down arrow) from the Eclipse toolbar. I have show that icon in the below image. Then click the ‘New’ button and create a AVD. Finally it should look like the window in my image.
Hello World Project Creation
Right click in your Eclipse’s Package Explorer and New -> Android Project. Give a project name, then select the Build Target. The build target should match the api version you have given at the time of AVD creation. Then fill the properties panel also.
Now the HelloWorld android project is ready to use. Open the HelloWorld.java from the project source. You should have a HelloWorld class source code similar to the below.
package com.javapapers.android;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Notice that you don’t have a main method. It is not needed. This HelloWorld is based on the Activity class and onCreate method will be called on initiation.
Now lets add our HelloWorld part to it. Edit the code and add the following snipped to it. Import TextView also.
TextView tv = new TextView(this);
tv.setText("Hello World!");
then set the contentView to the TextView you have created
setContentView(tv);
Now your Android Hello World should look like
package com.javapapers.android;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello World!");
setContentView(R.layout.main);
}
}
Run your Android Hello World
Right click on the project ‘Run As -> Android Application’
The AVD (emulator) will get started and it will take a while to respond. AVD needs that time to initialize itself. Wait for 2 to 3 minutes. Keep an eye on the console, it will give you some background process status information. Then you see “Hello World!”.















I was (am) also a believer of the fact that “Phone is for just making/receiving calls and (very) occasional SMS”.
I think we almost got our old phones (mine was Nokia 2300) in the same time (say 7 years). My old phone was working pretty much like a mule for years. After coming to US, I gave it to my MOM and it still rocking :)
What a coincidence, I just got my iPhone 3GS its only 50$ now(ofcourse with the wife factor). I know, ppl will still call me that I am in “Stone Age”. I am used to this comment with my old phone for years.
Let us start the countdown to launch a “Rocket” from our phones.
Thanks for posting the tutorial for setting up android environment. It is very useful.
Thank, eye-opening.
Thanks for posting this, its good
Its really informative blog…
“writing Hello World is not about learning the language. It is all about learning the setting up of the development environment, how to compile, interpret / execute.”
Such an obvious statement. And yet I’ve never seen it stated so plainly before.
So, for de-constructing the essence of Hello World, I salute you.
Nice and Simple explanation about Android.
I request you continue on writing more android articles.
Its nice………
Can you post me some advanced concepts like sqlite db in Android.
very nice article…..
Please post some more aritcles…..
Nice and good article
please post more android articles.
Really very good blog.. It is very much helpful for those developers who are new to android platform..
you did not write about implementing it on the device, please do it, your posts have more readability
These tutorials are always helpful for those of us just starting out on these types of things! Thank you for posting it, I’ll be referring back to this soon, as I hope to program a few Android apps this summer.
This made my interest’s towards Android.
Nice…really very useful..expecting some more concepts on Android
Just what I needed to get started. One internets to you, dear sir!
Machan (People in southside of india call the very close friends)..
Your way of explanation is too good. I am become fan of your explation
nice……………keep it up…..
nice……………keep it up…..
nice article
MeeToo want to add thanks for HelloWorld-On-Android experience :)
Greetings from München. My main mobile still is a 4y+ Nokia of the 1.3-MPixel gen. Will stay with the Android-Similator for a while :)
Nice Explanation..! It creates interest in exploring. Please post on “How to launch it on device? “.
Give me article on thread in java ………
hi Sir ,
ur style of explation is very well n
simple.
anyone can understand easily,
so bst luck for this n b continue with ur mission.
if possible thn publish book of ur simple language.
nice easy to follow post, thank you sir.
Nice post…thanx for sharing …
Getting the below error
[2011-09-08 07:52:02 - AndroidHelloWorld] The connection to adb is down, and a severe error has occured.
[2011-09-08 07:52:02 - AndroidHelloWorld] You must restart adb and Eclipse.
[2011-09-08 07:52:02 - AndroidHelloWorld] Please ensure that adb is correctly located at ‘C:\Program Files\Android\android-sdk\platform-tools\adb.exe’ and can be executed.
nice work brother
nice work bro
very nice work . if u give more information about it then we fell beter
Sir, Please tell us more android. I am new to this field. I succeed in making a hello world app. Give us more tutorial.
Thanks.
expecting more android aritcles.. come on
Nice post thanks for posting, very informative, have you any extra snippets for Android for Motorola?, please post !
Hi Joseph, thanks for nice post! It’s really good for me – a beginner.
Hi Sir,
Language you used , look and feel of blog was superb .
Thanking you,
Praveen G
Thank you for the post. It was very helpful
you simply rocks….!!
It’s really nice blog and very good idea, thanks for sharing
a new approach to android fr novice guys..
All of your posts are nice. Thanks for sharing.
Hi,
I was trying to create my first Android app yesterday, also a Hello World program. Unfortunately, I am getting some errors when I try to build the project.the bellow msg was apper.what can i do sir.
[2011-12-19 10:22:19 - AndroinHelloWorld] Android Launch!
[2011-12-19 10:22:19 - AndroinHelloWorld] adb is running normally.
[2011-12-19 10:22:19 - AndroinHelloWorld] Performing com.example.AndroidHelloWorld.AndroinHelloWorld activity launch
[2011-12-19 10:22:19 - AndroinHelloWorld] Automatic Target Mode: launching new emulator with compatible AVD ‘My_avd’
[2011-12-19 10:22:19 - AndroinHelloWorld] Launching a new emulator with Virtual Device ‘My_avd’
[2011-12-19 10:22:27 - Emulator] emulator: WARNING: Unable to create sensors port: Unknown error
[2011-12-19 10:22:27 - Emulator] emulator: emulator window was out of view and was recentered
[2011-12-19 10:22:27 - Emulator]
[2011-12-19 10:22:27 - AndroinHelloWorld] New emulator found: emulator-5554
[2011-12-19 10:22:27 - AndroinHelloWorld] Waiting for HOME (‘android.process.acore’) to be launched…
[2011-12-19 10:22:59 - AndroinHelloWorld] HOME is up on device ‘emulator-5554′
[2011-12-19 10:22:59 - AndroinHelloWorld] Uploading AndroinHelloWorld.apk onto device ‘emulator-5554′
[2011-12-19 10:22:59 - AndroinHelloWorld] Installing AndroinHelloWorld.apk…
am the begginer for android.ur explanation is nice and easily understandable.i was make the hello world program with the help of your site. there is no error but the required output will not come.plz help me sir.only blank emulator will be appeared when i was run this program.
i did the wireup .i tried running the android project but not getng the exact output.the screen just blinks first.i found a folder called assets empty.are there any contents to be included in it.
can you post tutorial beyond hello world pls
Hi Joe,
I have my complete android setup, done last year. After reading this i am going to look it back.
Thanks.
please specify eclipse version and url to download for android development
now i am going to do hello world project in android
Thanks for such a awesome article
Hi Sir,
Thanks for nice article.
I have use this program but didn’t get the output, program is running fine.
then I have changed the last line,
setContentView(tv);
insteed of
setContentView(R.layout.main);
so I got output.
Cool post! Its has become so easy to make a simple app now!!
I runned my android hello world using eclipse classic in android platform 4.15 and i used adt plugin 16.0 version.When click run,it shows emulator and a android logo on black scren, then the AVD gets disconnected automatically without displaying message in emulator.Help me pls.I tried it several times.
plz can u give me the solution that how can i generate the lyrics of the songs in the Android player…its urgent to give me the solution for it..as soon as posible…
Nice article sir
I would suggest to use Android phone as testing device since some of the services like location, bluetooth, google in built services, gyrosensor etc will not work in emulator. Its pretty simple and easy too to test in Android device. Just plugin and play with your developed app, no need to wait till emulator starts working :).
Sir,I want to know whether we can use our normal mobile for executing java programs…….is this possible!!!
if so can u tell me how can i run java program on my mobile…….!
pls reply!!!
Pingback: Android Manifest
Good Dude
This article inspired me to set up the env for android app development. I faced issues with the cache. Each time I change a piece of code, the changes are not being reflected. I tried clearing the files under \.android\cache and uninstalling the application in emulator(Settings –> app –> Uninstall my app), but nothing helped.
Pingback: Get User Input in Android
You are really rocking
It works absolutely nice. Can you write on displaying Indic Language Text in android?
I want to display Marathi text in my application.
Sure I will write a tutorial soon on displaying Indic language text in Android.
This website is well designed and I liked it so much. Whoever is the developer, hats off to him!
Pingback: Android Intent
I always enjoy your articles and for sure you are a great man.
I enjoyed the post. I am also a believer of the fact that “Phone is for just making/receiving calls and (very) occasional SMS”. I very recently changed my phone and got introduced to a smart phone. My first one.
very nice tutorial you can also check this one
http://pavanhd.blogspot.in/2012/09/android-hello-world-example.html
Hiii all,
I have launched my emulator and my app is there on the screen but when i click on the icon of my tab only splash screen comes for 2 or 3 sec and then again it returns to the home screen.
MY avd Configuration
Device Name- 5.1 ” WVGA(400* 800)mdpi
Target- Android 4.2.2- API level 17
RAM -512MB (**although my RAM is 2 GB but there i am not allowed to give it more than 512**)
VM heap- 32
Internal Storage -500
error in log- 2013-05-11 13:36:32 – SplashScreen] Failed to install SplashScreen.apk on device ‘emulator-5554!
[2013-05-11 13:36:32 - SplashScreen] (null)
[2013-05-11 13:36:33 - SplashScreen] Launch canceled!
I have already restarted my device, i hav increased heap size, i have changed the device but nothing is working ………..Please help