Home > Android Tools > Setting up Android Application Development With Eclipse

Setting up Android Application Development With Eclipse

January 12th, 2009 Leave a comment Go to comments

We will see how to setup Android development environment on a Windows machine.

To develop Android applications Android SDK is required. Currently released SDK version is 1.0r2. The latest SDK can be downloaded from this URL

Download the android-sdk-windows-1.0_r2.zip file.

Unzip the downloaded archive file to say c drive in C:\android-sdk-windows-1.0_r2 folder on your disk.

We are going to use Eclipse for developing Android applications. So let’s see how to configure the Eclipse to use Android SDK.

To develop Android application in Eclipse an eclipse plug-in ‘Android Development Tools’ (ADT) is required. Let’s see how to install the ADT plug-in for eclipse 3.3:

Steps to install ADT plug-in:

1. Start eclipse. Go to Help > Software Update > Find and install

2. Choose option Search for new feature to install.

3. Click on the button as New Remote Site. Add the name of the remote site as ‘Android Plug-in’ and put the URL, as shown in the image:

https://dl-ssl.google.com/android/eclipse/

01_addremotesite1

4. Check the newly added Remote Site also check the Discovery Site option, as shown in the image. Also select the Automatically select mirrors option.

02_updateoptions

Selecting the Discovery site is useful incase your eclipse environment does not have required plug-ins for the ADT plug-in.

5. Click on Finish.

6. The update window will show Android Plugin and Discovery site option.

7. Expand the Discovery site option so that content of the discovery site will be loaded.

8. Select (check) the android plug-in option. Sometimes this may show error as
‘ Android Editors (0.8.0.v200809220836-110569) requires plug-in “org.eclipse.wst.sse.ui”‘

9. Click on the ‘Select Required’ button. The required plug-ins will be selected from the Discovery site. Click next.

selectrequired

10. License agreement will be shown. To install plug-in select Accept terms and click Next.

11. Click Finish.

12. A warning message will be shown as plug-in is not signed. But you can safely install the plug-in by clicking Install All option.

13. Restart Eclipse.

Now your plug-in is installed. You have to initialize the plug-in to use the Android SDK that we downloaded earlier.

1. Go to the android Windows > Preferences menu. Eclipse Preference window will be opened.
2. Select Android from the left hand size menu (you can use the filter box to search quickly).
3. Click on the Browse button and select the location of the SDK in our case C:\android-sdk-windows-1.0_r2.
4. Click Apply and then Ok.

Now the plug-in is completely installed and you can start with the application development.

Creating an Android Project
Following are the steps to create Android project in eclipse

1. Select File > New > Android Project.

2. Select ‘Create a new Project in workspace’ option to create a new project. Provide the project name, base Package name, application main Launcher activity and Application Name as shown.
04_createandroidproject2

3. A new Eclipse Android project will be created. The project will have main activity class and Resource (R) class defined. A res folder containing application resources and AndroidManifest.xml file will also be generated.

Running the application:
To run the application Open the Run dialog. In the Run dialog select the Android Application and click on New Configuration.
Provide the configuration name and project name as follows (use default values for rest of the fields).

05_createlauchconf

Click on apply and click run.

The emulator will be started and the application’s main activity will call.

Debugging the application
To run the application in debug mode, choose eclipse Debug button and select the application launch configuration.
The application will go into the debug mode when the application reaches any breakpoints.

Using Logcat:
ADT provide a window called LogCat. The window can be opened from Window > Show view > LogCat. (You may have to click on others to see the complete list of available views).
The logcat view show system log messages as shown,

06_androidlogcatview

The application can also log message that will be shown in the Logcat view. The application can Log message with ‘Log’ class. Use methods Log.v (verbose), Log.d (debug), Log.i (info), Log.w (warning) and Log.e (error) as per the required log levels.

DDMS Perspective:
ADT come with an eclipse perspective called as DDMS perspective. Go to Windows > Open Perspective > DDMS.
The DDMS perspective shows windows like Devices, Emulator Control, File Explorer, Heap Status, and Thread Status.

07_eclipseddms-perspective

Devices window shows the currently running emulator instance. The window also shows the information about the application processes running on the emulator along with their pids. The window also provide options like ‘Debug Selected Process’, Update Process Thread and Heap status, Stop process and Capture Emulator screen. When Update Thread and Heap status option is selected the process Thread and Heap status can be seen in Head and Thread windows.

The Emulator Control Window provide functionality like sending SMS or Voice message to the emulator, Setting the emulator location co-ordinates etc.

The File Explorer shows the files and folders present on the emulator. The window also provides functionality to push a file on Device (emulator), Pull file from Emulator, Delete Selected files. The controls are present at the upper right corner.

The Logcat window is also shown as part of the DDMS perspective.

Now your Android development environment is all set and you also how to use the android tools. So now start developing Android Applications!

  • parth

    I just installed eclipse with adt. I followed the steps and tried creating a project. The file hierarchy gets created, but it does never show up on the eclipse adt file explorer. Nor does any of the AVD virtual devices on the devices list.

    What could be going wrong?
    Have you encountered any such errors.

    thanks and Regards,
    Parth

  • parth

    By the way my android version is 1.5,
    For eclipse I tried ganymade sr2, ganymade, RCP and java versions.

  • zeeshan

    file hierarchy is shown on file explorer only when the project is running. and also AVD virtual devices is shown only when the emulator is running.
    So when emulator is running , you can see it in Devices view. And when you click on the emulator name(eg. emulator -5554),its file structure is displayed on file explorer.
    If still problem not solved, give more details. We will definitely try to solve it.