If you will not be using Eclipse for your Android development, you can skip to the next section.

If you have not yet installed Eclipse, you will need to do that first. Eclipse can be downloaded from the Eclipse Web site. The “Eclipse IDE for Java Developers” package will work fine.

Next, you need to install the Android Developer Tools (ADT) plug-in. To do this, go to Help | Install New Software… in the Eclipse main menu. Then, click the Add button to add a new source of plug-ins. Give it some name (e.g., Android)    and    supply    the    following    URL: That should trigger Eclipse to download the roster of plug-ins available from that site:

7Eclipse ADT plug-in installation 

Check the checkbox to the left of “Developer Tools” and click the Next button. Follow the rest of the wizard to review the tools to be downloaded and  their  respective  license  agreements.  When  the  Finish  button  is enabled, click it, and Eclipse will download and install the plug-ins. When done, Eclipse will ask to restart – please let it.

Then, you need to teach ADT where your Android SDK installation is from  the preceding section. To do this, choose Window | Preferences from the Eclipse main menu (or the equivalent Preferences option for OS X). Click on the Android entry in the list on the left: Android app.


Then, click the Browse… button to find the directory where you installed the SDK. After choosing it, click Apply on the Preferences window, and you should see the Android SDK versions you installed previously. Then, click OK, and the ADT will be ready for use.

Install Apache Ant

If you will be doing all of your development from Eclipse, you can skip to the next section.

If you wish to develop using command-line build tools, you will need to install  Apache  Ant.  You may have this already from previous  Java development work, as it is fairly common in Java projects. However, you will need Ant version  1.8.1, so double-check your current copy  (e.g., ant -version) to ensure you are on the proper edition.

If you do not have Ant, you can obtain it from the Apache Ant Web site the basic steps are:

  1. Unpack the  ZIP  archive  wherever  it  may  make  sense  on  your machine
  2.  Then Add a JAVA_HOME environment variable, pointing to where your JDK is installed, if you do not have one already
  3. Add an ANT_HOME environment variable, pointing to the directory where you unpacked Ant in the first step above
  4. Add $JAVA_HOME/bin and $ANT_HOME/bin to your PATH
  5. Run ant -version to confirm that Ant is installed properly

Set Up the Emulator

The Android tools include an emulator, a piece of software that pretends to be an Android device. This is very useful for development – not only does it mean you can get started on Android without a device, but the emulator can help test device configurations that you do not own.

The Android emulator can emulate one or several Android devices. Each configuration you want is stored in an “Android Virtual Device”, or AVD. The  SDK  and  AVD  Manager, which you used to download the SDK components earlier in this chapter, is where you create these AVDs. Android app.

If you do not have the SDK and AVD Manager running, you can run it via the android command from your SDK’s tools/ directory, or via Window | SDK and AVD Manager from Eclipse. It starts up on a screen listing the AVDs you have available – initially, the list will be empty:

9Android SDK and AVD Manager

Click the New… button to create a new AVD file. This brings up a dialog where you can configure what this AVD should look and work like:

10Adding a New AVD

You need to provide the following:
  • A name for the AVD. Since the name goes  into  files  on  your development machine, you will be limited by filename conventions for your operating system (e.g., no backslashes on Windows).
  • The Android version you want the emulator to run (a.k.a., the “target”). Choose one of the SDKs you installed via the drop-down list. Note that in addition to “pure” Android environments, you will have options based on the third-party add-ons you selected. For example, you probably  have some options  for setting up AVDs containing the Google APIs, and you will need such an AVD for testing an application that uses Google Maps.
  • Details about the  SD  card  the  emulator  should emulate.  Since Android devices invariably have some form of “external storage”, you probably want to set up an SD card, by supplying a size in the associated  field.  However,  since  a  file  will  be  created  on  your development machine of whatever size you specify for the card, you probably do not want to create a 2GB emulated SD card. 32MB is a nice starting point, though you can go larger if needed.
  • The “skin” or  resolution  the emulator  should run  in.  The skin options you have will depend upon what target you chose. The skins let you choose a typical Android screen resolution (e.g., WVGA800 for 800×480). You can also manually specify a resolution when you  want to test a non-standard configuration.

You can skip the “Hardware” section for now, as changing those settings is usually only required for advanced configurations.

The resulting dialog might look something like this:

11Adding a New AVD (continued)

Click the Create AVD button, and your AVD stub will be created.

To start the emulator, highlight it in the list and click Start… You can skip the launch options for now and just click Launch. The first time you launch a new AVD, it will take a long time to start up. The second and subsequent times you start the AVD, it will come up a bit faster, and usually you only need to start it up once per day (e.g., when you start development). You do not need to stop and restart the emulator every time you want to test your application, in most cases.

The emulator will go through a few startup phases, first with a plain-text “ANDROID” label:

…then a graphical Android logo:

12 13

before eventually landing at the home screen (the first time you run the AVD, shown below) or the keyguard:

14   15

If you get the keyguard (shown below), press the MENU button, or slide the green lock on the screen to the right, to get to the emulator’s home screen:

Set Up the Device

You do not need an Android device to get started in Android application development.  Having one is a  good idea before you try to ship an application  (e.g., upload it to the Android Market). And, perhaps you already have a device-maybe that is what is spurring your interest in developing for Android.

The first step to making your device ready for use with development is to go into the  Settings application on the device.  From there,  choose Applications, then Development. That should give you a set of check-boxes of development-related options to consider:

16Android device development settings

Generally, you will want to enable USB debugging, so you can use your device with the Android build tools. You can leave the other settings alone for now if you wish, though you may find the “Stay awake” option to be handy, as it saves you from having to unlock your phone all of the time while it is plugged into a USB.

Next, you need to get your development machine set up to talk to your device. That process varies by the operating system of your development machine, as is covered in the following sections.

Step #1: Windows

When you first plug in your Android device, Windows will attempt to find a driver for it.  It is possible that,  by virtue of other software you have installed, the driver is ready for use. If it finds a driver, you are probably ready to go. If the driver is not found, here are some options for getting one.

Windows Update

Some versions of Windows (e.g., Vista) will prompt you to search Windows Update for drivers. This is certainly worth a shot, though not every device will have supplied its driver to Microsoft.

Standard Android Driver

In your  Android  SDK  installation,  you will find a  google-usb_driver directory, containing a generic Windows driver for Android devices. You can try pointing the driver wizard at this directory to see if it thinks this driver is suitable for your device.

Manufacturer-Supplied Driver

If you still do not have a driver, search the CD that came with the device (if any) or search the Web site of the device manufacturer.  Motorola, for example,  has  drivers  available  for  all  of  their  devices  in  one  spot  for

Odds are decent that simply plugging in your device will “just work”. You can see if Android recognizes your device via running adb  devices in a shell (e.g., OS X Terminal), where adb is in your platform-tools/ directory of your
SDK. If you get output similar to the following, Android detected your  device:

List  of  devices  attached HT9CPP809576   device

If you are running Ubuntu  (or perhaps other Linux variants), and this command did not work, you may need to add some udev rules. For example,

here is a 51-android.rules file that will handle the devices from a handful of manufacturers

  • SUBSYSTEM==”usb”,  SYSFS{idVendor}==”0bb4″,  MODE=”0666″
  • SUBSYSTEM==”usb”,  SYSFS{idVendor}==”22b8″,  MODE=”0666″
  • SUBSYSTEM==”usb”,  SYSFS{idVendor}==”18d1″,  MODE=”0666″
  • SUBSYSTEMS==”usb”,  ATTRS{idVendor}==”18d1″,  ATTRS{idProduct}==”0c01″, MODE=”0666″,  OWNER=”[me]”
  • SUBSYSTEM==”usb”,  SYSFS{idVendor}==”19d2″,  SYSFS{idProduct}==”1354″,  MODE=”0666″
  • SUBSYSTEM==”usb”,  SYSFS{idVendor}==”04e8″,  SYSFS{idProduct}==”681c”,  MODE=”0666″

Drop that in your  /etc/udev/rules.d  directory on  Ubuntu,  then either reboot the computer or otherwise reload the udev rules (e.g., sudo service udev reload). Then,  unplug and re-plug the device and see if it is detected.


This post contain content of the book Android Programming Tutorials by Mark L. Murphy below is the link of complete book Android Programming Tutorials