In this tutorial, we show you how to create a simple "Hello World" Android project in Eclipse IDE + ADT Plugi n, and run it with Android Virtual Device (AVD). The Eclipse ADT plugin provided easy Android project creation and management, components drag and drop, auto-complete and Many useful features to speed up your Android development cycles.
Summary steps to develop an Android application:
- Install Android SDK
- Install ADT Eclipse Plugin
- Create an Android Virtual Device (AVD)
- Create Android Project with Eclipse (Wizard)
- Code it ...
- Start it in Android Virtual Device (AVD)
Tools used in this tutorial:
- JDK 1.6
- Eclipse IDE 3.7, Indigo
- Android SDK
1. Install Android SDK
Visit this Android SDK page, choose which platform and install it.
In the Android SDK installed folder, run "Android SDK Manager", choose what the Android version you want to develop.
2. Install ADT Eclipse Plugin
To integrate the Android SDK with the Eclipse IDE, you need to install Eclipse ADT plugin. Refer to this official guide– "Installing the ADT Plugin".
In the Eclipse IDE, select "Help", Install New software ... ", and put below URL:
https://dl-ssl.google.com/android/eclipse/
Note
In my case, above ADT plugin are taking years to download and no idea why. If you is facing the similar problem, just download and install the ADT plugin manually, refer to this ADT plugin trouble Shooting guide.3. Create an Android Virtual Device (AVD)
In eclipse, you can access the 'Android Virtual Device (AVD)' in Eclipse toolbar. Click "New" to create a AVD.
Later, Eclipse would deploy the application into this AVD.
4. Create Android Project
In Eclipse, select "File--New project ....", "Android project", and input your application detail. Eclipse would create all the necessary Android project files and configuration.
5. Hello World
Locate the generated activity file, and modify a bit to output a string "Hello world".
File:HelloWorldActivity.java
Package Com.mkyong.android;import Android.app.activity;import Android.os.bundle;import Android.widget.TextView; public class Helloworldactivity extends activity { /** called when the activity is first created. */ @Override
public void OnCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); TextView Text = new TextView (this); Text.settext ("Hello World, Android-mkyong.com"); Setcontentview (text);} }
6. Demo
Run it as "Android application", see output.
Press "Home" button (on right hand side), and you'll noticed that "HelloWorld" application are deployed successfully on T He Android virtual device.
Note
This tutorial was more than example driven, not much explanation. For detail and complete explanation, please refer to the official Android developer Hello World Tutorial.
Firewall ...
In My computer, the COMODO firewall is installed and blocked the deploying process, caused the connection between Eclipse ADT and AVD are blocked and failed to deploy. Just Make sure your firewall are configured properly, or Just turn it off for Android development:)
Debug Android application on real device
Sometime, "
Android Virtual DeviceEnough to test some real phone functionalities, such as LED light, sensor and etc. Then you should refer to the "to" debug Android application on real device. Download Source codedownload it–android-helloworld.zip (KB) References
- Android Developers