Menu Search
Jump to the content X X
Smashing Conf Barcelona

You know, we use ad-blockers as well. We gotta keep those servers running though. Did you know that we publish useful books and run friendly conferences — crafted for pros like yourself? E.g. our upcoming SmashingConf Barcelona, dedicated to smart front-end techniques and design patterns.

Getting The Best Out Of Eclipse For Android Development

Getting into Android development can be quite a challenge, particularly if you’re new to Java or Eclipse or both. Whatever your past experience, you might feel tempted to start working away without checking that you’re making the best use of the IDE. In this article, we’ll go over a few tips, tools and resources that can maximize Eclipse’s usefulness and hopefully save you a few headaches. You might of course already be familiar with some (or all) of them and even be aware of others that we haven’t covered. If so, please do feel free to mention them.

I’ve used Eclipse for Java development on and off for a few years, having recently started learning Android casually. I’m surprised at the lack of easily digestible material online about basic aspects of Android development, such as the topic of this article. I’ve found some useful information out there in disparate locations that are not particularly easy to come across. Most of the online content is still in the official Android Developer Guide, but it has to be said that it is pretty limited in practical material.

Further Reading on SmashingMag: Link

The aim here, then, is to provide a concise overview of Android development tools specifically in Eclipse. If you’ve already started developing for Android, you will almost certainly have come across some of them, but a few might be new to you, especially if you’re learning Android casually or part time. If you’re approaching Android as a Java developer and are already accustomed to Eclipse, you’ll likely grasp this material well.

Get To Know Eclipse Link

Going over some features of Eclipse itself that would be useful for developing Android projects would be worthwhile. If you already know your way around Eclipse, you can probably skip these first few sections, because they’re really aimed at people who are learning to use the IDE purely for Android development. Later sections include tips on using Eclipse specifically for Android, so you might find a bit or two in there that you haven’t explored yet.

The Eclipse IDE, with the “Hello Android” project open.

Eclipse has a huge amount of flexibility for creating a working environment for your development projects. Many display options, tools and shortcuts in Eclipse enable you to interact with your projects in a way that will make sense to you directly. Having been an Eclipse user for a reasonable amount of time now, I still discover features in it that I had no idea existed and that could have saved me a lot of hassle in past projects.

Explore Perspectives Link

The Eclipse user interface provides a variety of ways to view the elements in any project. When you open Eclipse, depending on which “perspective” is open, you will typically see the screen divided into a number of distinct sections. In addition to the code editing area, you should see various aspects of the project represented in particular “views.”

A perspective in Eclipse is a group of views arranged to present a project in a particular way. If you open the “Window” menu, then select “Open Perspective,” you will usually see at least two options: “Debug” and “Java.” The Java perspective will likely form the basis of your Android development process; but for debugging, there is an Android-specific perspective called DDMS. Once you have set a perspective, you can still make alterations to the visible views, as well as adjust the layout by dragging the view areas around to suit yourself.

In general, when developing Android projects, some variation of the Java perspective is likely to be open, with the option of a few additional views, such as “LogCat,” where you can send and read the runtime output of your app. The Dalvik Debug Monitor Server (DDMS) perspective will likely be useful when the time comes to debug your Android applications. The tools in this perspective come as part of the Android software development kit (SDK), with Eclipse integration courtesy of the Android Developer Tools (ADT) plugin. The DDMS perspective provides a wide range of debugging tools, which we’ll cover in brief later on.

Make Use Of Views Link

By default, the Java perspective contains the main area to edit code and a handful of views with varying levels of usefulness for Android projects:

  • Package Explorer
    This provides a hierarchical way to explore your projects, allowing you to browse and control the various elements in them through a directory structure.
  • Outline
    Displays an interactive representation of the file currently open in the editor, arranged as logical code units, which can be useful for quickly jumping to a particular point in a big file.
  • Problems
    Lists errors and warnings generated at the system level during the development process.
  • Javadoc
    Useful if you’re creating your own documentation using Javadoc or using other language resources that have this documentation.
  • Declaration
    Particularly useful if your Android projects have a lot of classes and methods. You can click on a variable or method in your code to see its outline here, and then click within the view to jump to the point where the item is declared.

You can open new views in Eclipse by selecting “Show View” in the Window menu and clicking from there. Many of the available views won’t likely be of any use to your Android project, but it is worth experimenting with them. If you open a view and decide that you don’t want to display it after all, simply close it. Adjust or move open views to different locations in Eclipse by clicking and dragging their edges or the tabbed areas at the top.

Java Views Relevant to Android Development Link

The ADT plugin for Eclipse includes a variety of resources for Android development within the IDE, some of which we’ll cover in the sections below. Eclipse has additional views for general Java programming, some of which naturally have a greater potential for usefulness in Android development but don’t appear by default in the Java perspective. In my experience, views that are useful for Android development include “Call Hierarchy,” “Type Hierarchy” and “Tasks.”

The Call Hierarchy view displays an interactive list of the calls for any particular method, class or variable, so you can keep track of where your code excerpts are being called from. This is particularly useful if you’re altering existing code and need a sense of what will be affected.

The Call Hierarchy view for a method in one of my projects.

The Type Hierarchy view is relevant to Java projects that involve inheritance, which basically means that it’s relevant to all Android projects. Whenever you have a class that extends another class, this is inheritance and, thus, an instance when the Type Hierarchy view can be informative. If you’re not yet familiar with inheritance in Java, taking the time to at least read up on the basics4 is well worth it, because the technique is key to Android programming.

The Type Hierarchy for a user interface element in an Android project.

The Tasks view is one I personally find helpful, but it really depends on how you choose to organize your projects. Think of the Tasks view as an interactive to-do list. For example, to add a task when you haven’t quite finished a particular bit of implementation but need to address something else right away, write a code comment, then right-click in the border area just to the left of the editor section, choose “Add Task,” and set your options from there. Once tasks are in a project, you can read them in the Tasks view, jumping to an individual task in your code by selecting it here. Tasks are also highlighted in the right-hand border of the editor.

The Tasks view, with a random comment in the “Hello Android” project.

Android Debugging Views Link

The DDMS perspective contains several views for Android development and debugging. When you first open the perspective, you might feel a little overwhelmed, particularly because the views are all presented side by side in a rather convoluted arrangement. Chances are that once you learn the purpose of one, you’ll decide whether it’s relevant to your project; for a basic project, many of them will not be.

If you feel that closing some views would make the interface an easier environment to work in, then go ahead and close them; you can always open them again later. Starting simple is sometimes best, and then adding elements over time as they become relevant. In the early stages, your Android project is not likely to be complex anyway.

Let’s go through each DDMS view5 in Eclipse, with a brief note on its purpose and use. The information is tailored to each view and so is pretty varied, but includes device, memory and process management.

The Devices view provides an overview of your running AVD emulators together with processes in operation, and it is the starting point for exploring your projects for the purpose of debugging. This view presents shortcuts to some debugging operations, so you can select your app’s processes from here to see the other debugging operations in action. In most cases, you can view information in the other DDMS views by selecting a running process in the Devices view while your app is running in an emulator, then using the buttons at the top of the view to capture debugging information. When you do this, you’ll see some of the other views being populated with data.

The Devices view, with a process selected for debugging.

The Allocation Tracker view is particularly useful for apps that have significant demands on performance. This view provides insight into how the Dalvik Garbage Collector is managing memory for your app. If you’re not familiar with garbage collection in Java, you might want to read up on it, as well as familiarize yourself with basic principles of efficiency6 in Java programming, such as variable scope7.

The Allocation Tracker view in the DDMS perspective.

The Emulator Control view enables you to emulate specific network contexts when testing your apps, allowing you to see how they function with varying constraints on speed, latency and network connectivity. A vital tool if your app depends on such external connections.

The Emulator Control view with telephony settings.

The File Explorer view enables you to access and control the device’s file system (not the file system in your application’s structure as with the Package Explorer view). Using this, you can copy files to and from the device’s storage system; for example, in the case of an app storing data on the user’s SD card.

Looking at the SD card directory on a virtual device using the File Explorer view.

The Heap view is another tool for analyzing and improving memory management in your app. You can manually control the Garbage Collector from this view. If you are unclear on how the constructs of your Java code relate to heap memory, this is another area you might want to read up on8.

The Heap view for a running app.

The Threads view enables you to access information about the threads running in your application. If you are unfamiliar with the concept of threads, then this view won’t likely be of use to you. Typically, an Android application runs in a single process on a device, but if you implement a deeper level of control9 over your app’s processing at the level of threads, then this view will be relevant.

The Threads view for a particular running process.

The LogCat view is useful for most Android apps, regardless of their complexity. A variety of messages are automatically outputted here when you run your app, but you can optionally use the view as your own custom log. You can create log messages in various categories, including “Debug,” “Info,” “Warning,” “Error” and “Verbose,” which is typically used for low-priority information such as development trace statements. In the LogCat view, you can then filter the messages in order to quickly scroll to those you’re interested in. The messages are also color-coded, making them a little easier to absorb.

The LogCat view as a virtual Android device starts up.

A DDMS perspective view can optionally be added individually to the Java perspective if you find it useful for development as well as debugging. Eclipse is designed to enable you to interact with the project’s elements any way you like, so don’t be afraid to experiment with the interface.

Exploit The Design Tools Link

The design tools in the ADT have undergone major improvements in recent releases, so if you’ve been disappointed by them in the past and perhaps opted for other tools to design your Android apps, having another look at them now is well worth it.

In the Graphical Layout view, you can view your designs with various settings for device software, hardware as well as orientation. The current version generally gives a greatly improved level of control over widgets, views and rendering than most previous versions. You can manage user-interface elements here using the graphical interface, rather than having to implement every aspect of your design in XML code.

The graphical view of an app’s XML layout.

Design and Graphical Utilities Link

The ADT plugin update of June 2011 introduced a variety of visual refactoring10 utilities. While your XML layout files are open in the editor, you can browse the options in Eclipse’s Refactoring menu for Android, choosing from various labor-saving tools such as “Extract Style11,” which provides a shorthand method of copying style attributes for reuse.

The Resource Explorer is a handy interactive way to explore your application’s resources without the hassle of searching the file structure in the “res” folder via the Package Explorer. Although not exclusively for design purposes, the tool is useful for checking what design resources are in your application’s structure. Depending on the app, your Resources directory12 might also contain menu, array, string and value items13.

The Resources Explorer showing the Resources directory for an app.

On the subject of resources, the Resources interface for any XML files in your app enables you to manage such data graphically, if you prefer not to handle the XML code manually. This can be an effective way to manage both elements and attributes for your application’s XML data.

A graphical view of the XML file for arrays in an app.

Various visual interaction tools for XML resources have gradually been added and improved in the ADT plugin. For example, the Manifest file can also be viewed graphically when you want to control the tags in it, including “Permissions,” “Application” and “Instrumentation.”

An application’s Manifest file, presented graphically.

Set Your Android Preferences Link

The “Eclipse Window” menu provides access to the Preferences settings for the environment as a whole, with a dedicated section for Android. You may have used this when you first installed the SDK but might not have been in there since then. It’s worth having a look through the options and experimenting with them to create the environment you want.

In the Android section, the “Build” settings include your saved edits to the project’s files, and they also point Eclipse to your keystore for signing the application. The LogCat section lets you set properties for appearance and behavior in the LogCat view. Other options include choosing properties for the DDMS, the code editors and the launch process for the emulator.

Use The Android Run Configuration Options Link

When you launch your Android project using the Run Configurations menu, you can choose from a range of additional options14 to suit the functionality of your app. With your Android project selected, choose the “Target” tab to see these options. The first section covers the more general launch parameters for the emulator, including control over speed and latency on the device. This feature is useful if your app depends on a network connection and you want to see how it functions with limited connectivity.

Emulator Command-Line Options Link

The “Target” tab also allows you to enter command-line options for the emulator that launches your app. Using these, you can tailor the appearance, properties and behavior of the emulator as it launches your app. A lot of options are here for various aspects of the device, including the following properties:

  • UI
    Includes scaling the display window and setting the DPI.
  • Disk image
    Includes the device’s SD card and cache memory.
  • Media
    Covers audio and radio properties.
  • Debugging
    Enables and disables specific debug tags.
  • Network
    In addition to network speed and latency, you can specify DNS and proxy servers.
  • System
    Includes slowing down the device CPU and setting the time zone.

For a full list, see the Developer Guide.

Choose Useful AVD Configurations Link

When you create virtual devices in Eclipse using the Android SDK and AVD Manager15, through the “Window” menu you can choose various settings, including API versions and hardware configurations, such as the size of the SD card and screen, plus optional hardware components. The sheer range of options can leave you wondering where to start, but the feature at least gives you some idea of how your apps will look and function on various devices.

Entering the details for a new AVD.

To create a virtual device, select “New,” enter a name and choose “Options.” You can edit your devices later if necessary. To start an AVD running, select it in the SDK and AVD Manager and click “Start.”

Choosing from a variety of AVDs to start running.

Some developers prefer configuration options that match the range of Android devices currently in use, which obviously vary widely, with multiple phone sizes and types, not to mention tablets16. There is no dedicated resource for finding this data, but a number of websites list these configuration details17 periodically, so you can do a quick Web search when testing an app for release to find the most current information.

It must be said that there is a real limit in value to using actual device settings, because the emulator is merely a guide: it doesn’t replicate the look and feel of different devices with any authenticity. These limitations are especially pertinent when you consider the third parties involved, such as HTC’s Sense interface, which will substantially alter your application’s UI. This is why testing on actual devices is also important, but that’s another topic. The range of devices running Android will obviously continue to expand, so the feasibility of covering a significant chunk of them becomes more and more remote.

Rather than focusing on actual devices in use, another way to approach the AVD configuration settings while you’re in Eclipse (i.e. when you’re still developing rather than testing) is to simply try to cover a range of settings and to explore particular hardware and software configurations that could affect your app’s functionality. Visually speaking, it goes without saying that a relative rather than fixed design will cope better with various screen sizes.

Get And Keep Yourself Acquainted With Developer Resources Link

As you’re by now aware, if you weren’t already, the Android Developer Tools plugin is what allows you to develop, run, test and debug Android applications in Eclipse, together with the software development kit. Like Eclipse itself, both the SDK and ADT plugins offer many tools, many of which you could very easily remain unaware of and only a few of which we have touched on in this article.

The Android development resources undergo regular updates. You might be one of those people who are always on the ball, but if you’re anything like me, you’ll rarely find the time to keep abreast of these developments, especially if (like me) Android development is not your full-time job.

The Android Developer Guide lists the various tools in the SDK18, many of which you will not need to access directly, because the ADT plugin and Eclipse will handle interaction with them. But it’s worth browsing the list fairly regularly, just to be aware of the tools available. Even if you’re only getting into Android casually, these utilities can make an enormous difference to how productive and enjoyable your app’s experience is. The Android Developers Blog19 is another good source to keep abreast of developments.

The ADT plugin itself comes with a wealth of features and is regularly updated. The Android SDK Guide also has a page on the plugin20, outlining versions and features; again, well worth checking out regularly, because there may be significant updates. Checking for updates in Eclipse through the “Help” menu is another good habit.

Android apps are, of course, extremely varied, so the utility of any given development tool is necessarily relative. Keeping a eye on updates to resources needn’t take up much time, because in many cases the updates will be irrelevant to you. But discovering the ones that are relevant could seriously improve your Android development efforts.

Following Best Practices Link

If you’re interested in developing a best-practices approach to managing and documenting your apps, check out Apache Maven21, which uses the project object model22 (POM). If you’ve already used Maven for Java development in Eclipse, the Android plugin23 and Integration tools will enable you to adopt the same development practices for your Android app. You can learn more about Maven on the Apache website24, and you can learn about getting started with it for Android on the Sonatype website.

Other Resources Link


Footnotes Link

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39

↑ Back to top Tweet itShare on Facebook

Sue Smith lives and works in Glasgow, Scotland doing Web, multimedia and mobile development plus a bit of writing. Sue began developing Android applications a short while ago, writes technical and educational material on a freelance basis, and has a number of comedy websites/ blogs, including Brain Dead Air Magazine. Started tweeting recently @BrainDeadAir.

  1. 1

    Eclipse. Yuck :)

    Although I’m primarily a developer, I like to work with tools that look and feel nice, Eclipse is just too bloated for my taste/needs. But then again, I haven’t done any Android development.

  2. 2

    Have you guys had any experience with JetBrains Intellij? I’ve been using it for a few months now and it is so much less annoying to deal with, quicker, just a much more pleasant experience to develop in. Obviously, this is all IMHO, but I’d check it out.

  3. 3

    Eclipse is a great but sometimes tricky IDE… takes some getting used to, but once you figure out it’s quirks, you’ll love it. One word of advice: learn the short-cuts… without them, it’s just another smart-ish text editor… It’ll make your live so much easier. Ctrl+Space, Ctrl+1, Ctrl+Shift+T or R, Ctrl+Alt+H, Alt+Arrows, Ctrl+Alt+Up/Down, Shift+Enter, Ctrl+M… just to name a few that I use all the time.

    • 4

      Great advice from Pavel – Thanks for mentioning shortcuts, they definitely make a huge difference..

  4. 5

    Anand Chowdhary

    November 5, 2011 10:30 pm

    You’re using Ubuntu! Amazing article though.

  5. 6

    Lawrence D’Oliveiro

    November 6, 2011 12:49 am

    Eclipse is optional. Google have provided good support for doing command-line builds of Android projects with Ant. This allows you to use your choice of editor, e.g. I prefer Emacs.

    Command-line builds also offer more flexibility for including custom build requirements. For example, ti5x ( requires the execution of custom Python scripts to build the included Master Library programs–all this happens automatically with just one build command.

  6. 7

    eclips…. yups that is great program for web developer, i used it to for 4 years for add or edit php, javascript, xml, etc…

  7. 8

    Getting into Android development can be quite a challenge, particularly if you’re new to Java or Eclipse or both.

  8. 10

    Eclipse IDE is quite effective in java development for Android platform. but does IntelliJ IDEA also works just as good as Eclipse or Net beans? Android development through command line build also provides flexibility and sophistication.

  9. 11

    That’s a good summary of the basics of using Eclipse for Android, i.e. Using Eclipse For Android 101… given the title of this article, I was expecting some advanced tips, like setting up AVDs to best match specific devices, indepth debugging, static code analysis plugins, etc.

  10. 12

    How can HTML and PHP be used in Android application development? Improve.
    In: PHP Programming, HTML, Android OS.

  11. 13

    Another perspective that I have found invaluable is the “Hierarchy View” perspective. This can be a real timesaver when debugging very complex layout.

  12. 14

    Is there a DS emulator for Android? No there is not. And I don’t think that it is possible!!

  13. 15

    Nice article! Even though I’ve used Eclipse a bit before, it wasn’t for Java or Android, so I didn’t know about most of these great tools! I’m glad to see that some ADT features (graphical UI editor especially) have been improved since I first peeked at them too.

  14. 16

    Nice tutorial.Its realy useful.Thank you for sharing.

  15. 17

    Viviane Delvequio

    November 16, 2011 10:35 am

    Nice tutorial!

    Also there is a development tool, based on Eclipse, that can make it even easier: the MOTODEV Studio for Android (

    Since it had been done strictly for Android development, it has a lot of tools related to this kind of work. : )

    It is free, it is for any android device and runs on MAC OS X, Windows and Linux. ; )

  16. 18

    Hi folks,

    I work with the development team for a tool called MOTODEV Studio for Android. It’s an contribution from Motorola for the Eclipse + Google ADT that includes both of them and adds some more features such as easy ways to work with localization files and databases, also wizard for creating activities based on pre-defined templates, some code snippets, integrated emulators, automatic code generation for some repetitive code, analysis of your code trying to find common errors, and etc. It can make our lives easier.

    Just reinforcing a point since some people get scare when the see our product for the first time: It comes from Motorola but is really an ‘Android IDE’, it works for any android version and any device, seriously. It is free – completely (you only need to create an account on MOTODEV site for downloading, no fees) – and it does not compete in any ways with Google or Eclipse, just complements them with some more functionalities.

    Take a look:

    If you have problems or need help, feel free to post questions in our discussion boards and our engineers will try their best to help:

    I hope it helps :)

  17. 19

    What is the role of sustainable development in android development?

  18. 20

    How Do You Clean Window Blinds?

  19. 21

    Courtney Joyce

    November 24, 2011 6:36 pm

    a fantastic resemblance to a human being. In modern times, androids or robots have become commonplace in science fiction stories and films.

  20. 22

    While looking at a layout in the Graphical Layout design window… how can I quick switch to French? Italian? German? So I can see how everything looks when translated?

  21. 23

    I know JAVA and have tried eclipse but don’t know how to code android programs in it. Please help me at


↑ Back to top