Get Started Developing for Android with Eclipse


There’s a lot to get excited about in mobile application development today. With increasingly sophisticated hardware, tablet PCs and a variety of software platforms (Symbian OS, iOS, WebOS, Windows Phone 7…), the landscape for mobile developers is full of opportunities — and a little complex as well.

So much choice can be overwhelming when you just want to get started building mobile applications. Which platform should you choose? What programming language should you learn? What kit do you need for your planned project? In this tutorial, you’ll learn how to start writing applications for Android1, the open-source mobile operating system popularized by Google.

Why Develop for Android?

Android is an open-source platform based on the Linux kernel, and is installed on thousands of devices2 from a wide range of manufacturers. Android exposes your application to all sorts of hardware that you’ll find in modern mobile devices — digital compasses, video cameras, GPS, orientation sensors, and more.

Android’s free development tools make it possible for you to start writing software at little or no cost. When you’re ready to show off your application to the world, you can publish it to Google’s Android Market. Publishing to Android Market incurs a one-off registration fee (US $25 at the time of writing) and, unlike Apple’s App Store which famously reviews each submission, makes your application available for customers to download and buy after a quick review process — unless the application is blatantly illegal.

Here are a few other advantages Android offers you as a developer:

  • The Android SDK is available for Windows, Mac and Linux, so you don’t need to pay for new hardware to start writing applications.
  • An SDK built on Java. If you’re familiar with the Java programming language, you’re already halfway there.
  • By distributing your application on Android Market, it’s available to hundreds of thousands3 of users instantly. You’re not just limited to one store, because there are alternatives, too. For instance, you can release your application on your own blog. Amazon have recently been rumoured4 to be preparing their own Android app store also.
  • As well as the technical SDK documentation5, new resources are being published for Android developers as the platform gains popularity among both users and developers.

Enough with the talk — let’s get started developing for Android!

Installing Eclipse and the Android SDK

The recommended environment for developing Android applications is Eclipse with the Android Development Toolkit (ADT) plugin installed. I’ll summarize the process here. If you need more detail, Google’s own developer pages6 do a good job of explaining the installation and configuration process.

  • Download the Android SDK7 for your platform (Windows, Mac OS X, or Linux).
  • Extract the downloaded file to somewhere memorable on your hard drive (on Linux, I use /opt/local/).
  • If you don’t already have Eclipse installed, download and install the Eclipse IDE for Java Developers8 package. For programming, Google recommends using Eclipse 3.5 (Galileo).
  • Run Eclipse and choose Help->Install New Software.
  • Click Add in the Available Software window.
  • Enter Android Development Tools in the Name field, and in the Location field.
  • Click OK and check Developer Tools in the list of available software. This will install the Android Development Tools and DDMS, Android’s debugging tool.
  • Screensot9
    Large image10

  • Click Next and Finish to install the plugin. You’ll need to restart Eclipse once everything is installed.
  • When Eclipse restarts, choose Window->Preferences and you should see Android listed in the categories.
  • You now need to tell Eclipse where you’ve installed the Android SDK. Click Android and then Browse to select the location where you extracted the SDK files. For example, /opt/local/android-sdk.
    Configuring ADT11
    Large view12
  • Click OK to have Eclipse save the location of your SDK.

Targeting Android Platforms

Before you can start writing applications for Android, you need to download the SDK platforms for the Android devices for which you want to develop apps. Each platform has a different version of the Android SDK that may be installed on users’ devices. For versions of Android 1.5 and above, there are two platforms available: Android Open Source Project and Google.

The Android Open Source Project platforms are open source, but do not include Google’s proprietary extensions such as Google Maps. If you choose not to use the Google APIs, Google’s mapping functionality won’t be available to your application. Unless you have a specific reason not to, I’d recommended you to target one of the Google platforms, as this will allow you to take advantage of Google’s proprietary extensions.

  • Choose Window->Android SDK and AVD Manager.
  • Click Available Packages in the left column and check the repository to show a list of the available Android platforms.
  • You can choose which platforms to download from the list, or leave everything checked to download all the available platforms. When you’re done, click Install Selected and follow the installation instructions.13
    Large image14

Once everything has been successfully downloaded, you’re ready to start developing for Android.

Creating a New Android Project

Eclipse’s New Project Wizard can create a new Android application for you, generating files and code that are ready to run right out of the box. It’s a quick way to see something working, and a good starting point from which to develop your own applications:

  • Choose File->New->Project…
  • Choose Android Project
  • In the New Project dialog, enter the following settings:
    Project Name: BrewClock
    Build Target: Google Inc. 1.6 (Api Level 4)
    Application Name: BrewClock
    Package Name: com.example.brewclock
    Create Activity: BrewClockActivity
    Min SDK Version: 4


After clicking Finish, Eclipse will create a new Android project that’s ready to run. Notice you told Eclipse to generate an Activity called BrewClockActivity? This is the code that Android actually uses to run your application. The generated code will display a simple ‘Hello World’ style message when the application runs.


The package name is an identifier for your application. When the time comes and you are willing to publish on Android Market, it’s exactly this identifier that will be used to track your application for updates, so it’s important to make sure it’s unique. Although we’re using the com.example.brewclock namespace here, for a real application it’s best to choose something like com.yourcompanyname.yourapplication.

SDK Versions

The Min SDK Version is the earliest version of Android on which your application will run. With each new release of Android, the SDK adds and changes methods. By choosing an SDK version, Android (and the Android Market) knows that your application will only run on devices with a version of Android later or equal than the specified version.

Running Your Application

Now let’s try running the application in Eclipse. As this is the first run, Eclipse will ask what type of project you are working on:

  • Choose Run->Run or press Ctrl+F11.
  • Choose Android Application and click OK.

Eclipse will now try to run the application on an Android device. At the moment, though, you don’t have any Android devices running, so the run will fail and you’ll be asked to create a new Android Virtual Device (AVD).

Android Virtual Devices

An Android Virtual Device (AVD) is an emulator that simulates a real-world Android device, such as a mobile phone or Tablet PC. You can use AVDs to test how your application performs on a wide variety of Android devices, without having to buy every gadget on the market.

You can create as many AVDs as you like, each set up with different versions of the Android Platform. For each AVD you create, you can configure various hardware properties such as whether it has a physical keyboard, GPS support, the camera resolution, and so on.

Before you can run your application, you need to create your first AVD running the target SDK platform (Google APIs 1.6).

Let’s do that now:

  • If you haven’t tried to run your application yet, click Run now (or hit Ctrl+F11)
  • When the target device warning pops up, click Yes to create a new AVD.
  • Click New in the Android SDK and AVD Manager dialog that appears.
  • Enter the following settings for the AVD:
    Name: Android_1.6
    Target: Google APIs (Google Inc.) - API Level 4
    SD Card Size: 16 MiB
    Skin Built In: Default (HVGA)
  • Click Create AVD to have Android build your new AVD.
  • Close the Android SDK and AVD Manager dialog.


Running the Code

Try running your application again (Ctrl+F11). Eclipse will now build your project and launch the new AVD. Remember, the AVD emulates a complete Android system, so you’ll even need to sit through the slow boot process just like a real device. For this reason, once the AVD is up and running, it’s best not to close it down until you’ve finished developing for the day.

When the emulator has booted, Eclipse automatically installs and runs your application:

Large image18

Building Your First Android Application

Testing generated code is all well and good, but you want to start building a real application. For this, we’ll step through a simple design process and build an application that you can deploy to your Android device.

Most developers (myself included) like a constant supply of good tea or coffee. In the next section of this article you’ll build a simple tea counter application to track how many cups of tea (brews) the user has drunk, and let them set a timer for brewing each cup.

You can download the complete code for this tutorial on GitHub19.

Designing the User Interface

One of the first steps to building any Android application is to design and build the user interface. Here’s a quick sketch of how the application’s interface will look:

Large image21

The user will be able to set a brew time in minutes using the + and - buttons. When they click Start, a countdown will start for the specified number of minutes. Unless the user cancels the brew by tapping the button again, the brew count will be increased when the countdown timer reaches 0.

Building the Interface

Android user interfaces, or layouts, which are described in XML documents, can be found in the res/layouts folder. The template code that Eclipse generated already has a simple layout declared in res/layouts/main.xml which you may have seen previously while the application was running on the emulator.

Eclipse has a graphical layout designer that lets you build the interface by ‘dragging’ and ‘dropping’ controls around the screen. However, I often find it easier to write the interface in XML and use the graphical layout to preview the results.

Let’s do this now by changing main.xml to match the design sketch above:

  • Open res/layouts/main.xml in Eclipse by double-clicking it in the Package Explorer.
  • Click the main.xml tab along the bottom of the screen to switch to XML view.

Now change the content of main.xml to:

# /res/layouts/main.xml
<?xml version="1.0" encoding="utf-8"?>
      android:text="Brews: " />
      android:id="@+id/brew_count_label" />
      android:textSize="40dip" />
      android:padding="10dip" />
      android:textSize="40dip" />
    android:text="Start" />

As you can see, Android’s XML layout files are verbose, but allow you to control virtually every aspect of elements on the screen.

One of the most important interface elements in Android are Layout containers, such as the LinearLayout used in this example. These elements are invisible to the user but act as layout containers for other elements such as Buttons and TextViews.

There are several types of layout views, each of which is used to build different types of layout. As well as the LinearLayout and AbsoluteLayout, the TableLayout allows the use of complex grid-based interfaces. You can find out more about Layouts in the Common Layout Objects22 section of the API documents.

Linking Your Layout With Code

After saving your layout, try running your application in the emulator again by pressing Ctrl+F11, or clicking the Run icon in Eclipse. Now instead of the ‘Hello World’ message you saw earlier, you’ll see Android now displays your application’s new interface.

If you click any of the buttons, they’ll highlight as expected, but don’t do anything yet. Let’s remedy that by writing some code behind the interface layout:

# /src/com/example/brewclock/
import android.widget.Button;
import android.widget.TextView;

public class BrewClockActivity extends Activity {
  /** Properties **/
  protected Button brewAddTime;
  protected Button brewDecreaseTime;
  protected Button startBrew;
  protected TextView brewCountLabel;
  protected TextView brewTimeLabel;


Next, we’ll change the call to onCreate. This is the method that gets called whenever Android starts your application. In the code that Eclipse generated, onCreate sets the activity’s view to be R.layout.main. It’s that line of code that tells Android to decode our layout XML document and display it to the user.

The Resource Object

In Android, R is a special object that is automatically generated to allow access to your project’s resources (layouts, strings, menus, icons…) from within the code. Each resource is given an id. In the layout file above, these are the @+id XML attributes. We’ll use those attributes to connect the Buttons and TextViews in our layout to the code:

# /src/com/example/brewclock/
public class BrewClockActivity extends Activity {
  public void onCreate(Bundle savedInstanceState) {

    // Connect interface elements to properties
    brewAddTime = (Button) findViewById(;
    brewDecreaseTime = (Button) findViewById(;
    startBrew = (Button) findViewById(;
    brewCountLabel = (TextView) findViewById(;
    brewTimeLabel = (TextView) findViewById(;

Listening For Events

In order to detect when the user taps one of our buttons, we need to implement a listener. You may be familiar with listeners or callbacks from other event-driven platforms, such as Javascript/jQuery events or Rails’ callbacks.

Android provides a similar mechanism by providing Listener interfaces, such as OnClickListener, that define methods to be triggered when an event occurs. Implementing the OnClickListener interface will notify your application when the user taps the screen, and on which button they tapped. You also need to tell each button about the ClickListener so that it knows which listener to notify:

# /src/com/example/brewclock/
// Be sure not to import
// `android.content.dialoginterface.OnClickListener`.
import android.view.View.OnClickListener; 

public class BrewClockActivity extends Activity
  implements OnClickListener {
  public void onCreate(Bundle savedInstanceState) {
    // Setup ClickListeners
  public void onClick(View v) {
    // TODO: Add code to handle button taps

Next we’ll add code that handles each of our button presses. We’ll also add four new properties to the Activity that will let the user set and track the brewing time, how many brews have been made, and whether the timer is currently running.

# /src/com/example/brewclock/
public class BrewClockActivity extends Activity
  implements OnClickListener {
  protected int brewTime = 3;
  protected CountDownTimer brewCountDownTimer;
  protected int brewCount = 0;
  protected boolean isBrewing = false;
  public void onClick(View v) {
    if(v == brewAddTime)
      setBrewTime(brewTime + 1);
    else if(v == brewDecreaseTime)
      setBrewTime(brewTime -1);
    else if(v == startBrew) {

Notice we’re using the CountDownTimer class provided by Android. This lets you easily create and start a simple countdown, and be notified at regular intervals whilst the countdown is running. You’ll use this in the startBrew method below.

The following methods are all model logic that handles setting the brew time, starting and stopping the brew and maintaining a count of brews made. We’ll also initialize the brewTime and brewCount properties in onCreate.

It would be good practice to move this code to a separate model class, but for simplicity we’ll add the code to our BrewClockActivity:

# /src/com/example/brewclock/
public class BrewClockActivity extends Activity
  implements OnClickListener {
  public void onCreate(Bundle savedInstanceState) {
    // Set the initial brew values

   * Set an absolute value for the number of minutes to brew.
   * Has no effect if a brew is currently running.
   * @param minutes The number of minutes to brew.
  public void setBrewTime(int minutes) {

    brewTime = minutes;

    if(brewTime < 1)
      brewTime = 1;

    brewTimeLabel.setText(String.valueOf(brewTime) + "m");

   * Set the number of brews that have been made, and update
   * the interface.
   * @param count The new number of brews
  public void setBrewCount(int count) {
    brewCount = count;

   * Start the brew timer
  public void startBrew() {
    // Create a new CountDownTimer to track the brew time
    brewCountDownTimer = new CountDownTimer(brewTime * 60 * 1000, 1000) {
      public void onTick(long millisUntilFinished) {
        brewTimeLabel.setText(String.valueOf(millisUntilFinished / 1000) + "s");

      public void onFinish() {
        isBrewing = false;
        setBrewCount(brewCount + 1);

        brewTimeLabel.setText("Brew Up!");

    isBrewing = true;

   * Stop the brew timer
  public void stopBrew() {
    if(brewCountDownTimer != null)

    isBrewing = false;

The only parts of this code specific to Android are setting the display labels using the setText method. In startBrew, we create and start a CountDownTimer to start counting down every second until a brew is finished. Notice that we define CountDownTimer's listeners (onTick and onFinish) inline. onTick will be called every 1000 milliseconds (1 second) the timer counts down, whilst onFinish is called when the timer reaches zero.

Avoiding Hard-Coded Text in your Code

To keep this tutorial code simple, I’ve intentionally written label strings directly in the code (e.g. "Brew Up!", "Start", "Stop"). Generally, this isn’t good practice, as it makes finding and changing those strings harder in large projects.

Android provides a neat way to keep your text strings separate from code with the R object. R lets you define all your application’s strings in an xml file (res/values/strings.xml) which you can then access in code by reference. For example:

# /res/values/strings.xml
<string name="brew_up_label">Brew Up!</string>

# /res/com/example/brewclock/

Now if you wanted to change Brew Up! to something else, you would only need to change it once in the strings.xml file. Your application starts to span dozens of code files which keeps all your strings in one place and makes a lot of sense!

Trying BrewClock

With the code complete, it’s time to try out the application. Hit Run or Ctrl+F11 to start BrewClock in the emulator. All being well, you’ll see the interface set up and ready to time your tea brewing! Try setting different brew times, and pressing Start to watch the countdown.

Large image24


In this short introduction to Android, you’ve installed the Android SDK and Eclipse Android Development Tools (ADT) plugin. You’ve set up an emulator, or virtual device that can test your applications. You’ve also built a working Android application which has highlighted a number of key concepts that you’ll use when developing your own Android applications.

Hopefully, this has whet your appetite for building mobile applications, and experimenting in this exciting field. Android offers a great way to start writing applications for a range of current and upcoming mobile devices. If you’ve built or are working on your own mobile app, be sure to let us know about it in the comments!

(ik), (vf)


  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

↑ Back to topShare on Twitter

Chris is a software developer working with Ruby, Rails and Android. In 2010, he founded Plymouth Software where he designs and builds applications for the web and mobile devices. As well as a fondness for travel and drinking tea, Chris writes about code, design and business on his blog at


Note: Our rating-system has caused errors, so it's disabled at the moment. It will be back the moment the problem has been resolved. We're very sorry. Happy Holidays!

  1. 1

    Great tutorial! Can’t wait to get started.

  2. 2

    Just Awesome

  3. 3

    Great! Thank you!

  4. 4


  5. 5

    Great article !
    Like to see *a lot* more of this !

    Already followed a 1-day seminar on building Android apps, and it’s not that easy for someone like me (webdesigner/developer).
    Step-by-step tutorials of Smashing quality would come in handy indeed. (or another e-book maybe ? )

  6. 6

    This is a really GREAT snapshot of android development! Smashing!!!

  7. 7

    Sooo much thanks, this is a great tutorial for begginers!!!!

    Greetings from Colombia!!!

  8. 8

    Sorry for diversion, but what desktop font are you using on Ubuntu? It’s really nice!

  9. 9

    Sorry for ranting but I can’t let this slip. “An SDK is built on Java” should probably be “THIS SDK is built on Java”. Describing SDK as something that is written for Java is just… wrong, as an SDK could be for any language.

  10. 10

    I totally agree with Tom. I’d love to see a lot more of these type of articles!

  11. 11

    Thanks to everyone for your comments!

    @Karl The font I’m using now is “Ubuntu”, the new default in 10.10 Maverick. The designers, DaltonMaag, have some other stunning fonts available.

    @Klesus Thanks for pointing out the typo, I’ve updated the post.

  12. 12

    Just in time =D

    I think Android is getting everyday more and more developers, and that post have become just in the right time for me =D

    Maybe one day you guys start a new site, droidtuts+


  13. 13

    Checkout the following Android tutorial:

    It walks the developer through building Conway’s Game of Life – the problem space is small enough to allow the developer to only focus on Google Android while still including sufficient elements to make for both an interesting and valid learning experience.

    Brett Kromkamp

  14. 14

    Thanks for this article!
    Though I think I saw “Comic Sans” somewhere…

  15. 15

    Thanks for this! How upward compatible are the different platforms? If I decide to write something for 1.6 (your example) will it run on 2.2 as well? I guess this shouldn’t be a problem but I’m completely new to Android so don’t shoot me :-)

  16. 16

    Useful stuff, thanks :) I have to ask if you used any of the articles here: as a reference? They cover a lot of the same points.

  17. 17

    Sweet post Chris. Once devs are ready to publish and would like extra help on promoting their app(s) they should take a peek at the lightweight GamerShots SDK to include in their projects –

  18. 18

    @ZizzelDaZuz It depends on what features of the SDK your app uses, but my experience has been that Android has good upward-compatibility.

    I’ve run into minor problems such as changing file storage paths in 2.2, but the changes are very well-covered in the SDK docs. Your code can query the current device to discover platform and capabilities, and act appropriately.

  19. 19

    A really clear, concise and well explained tutorial, which has proven to be extremely helpful as I’ve been struggling getting started with Android. More from this author please!

  20. 20

    Upward compatibiliy is not a problem yet, but some things are deprecated and could not be available on future phones.

  21. 21

    I got the same uncomfortable feeling when I saw that too…

  22. 22

    Great article. Thank you.
    I’m just starting with Android… with mobile apps… and this was perfect timing.

    I have a few errors popping up in Eclipse. I think I followed your tutorial to the dot, but I’m not sure now. would it be possible for you to post the full contents of This may help others, aswell :)

  23. 23

    This is a great tutorial. Can you write a tutorial for Android development using PhoneGap next?

  24. 24

    @pioSko: Thanks :) The source code for the tutorial is available at

    @Scott: Not tried PhoneGap – looks interesting though!

  25. 25

    I followed your tutorial and it is very useful, thank you very much
    I found a mistake, you writed
    but it should be

    It is very complete, but I miss a point where you explain how to put the app image.

    A tip for the web developers interested in developing android apps, take a look to phonegap, it is very useful for creating “native” iphone and android apps using html, css and javascript (and even blackberry, wm and symbian)

  26. 26

    I have a feeling this article was written to somehow express a “hate” toward Jobs’ recent prescon. Great response (slap) in his face.
    Keep up the good work SM.

  27. 27

    That’s nice!

  28. 28

    Web Designer Houston

    October 25, 2010 8:06 pm

    This is a really GREAT snapshot of android development! Smashing!!!

    I totally agree with Tom. I’d love to see a lot more of these type of articles!
    Thanks for sharing this!!!

  29. 29

    great article i really want to try Android :)

  30. 30

    Thanks, really appreciate all the comments! :)

    @Laura Hadn’t seen that blog, but would like to add it to a list of useful resources for Android developers that I’m compiling.

  31. 31

    Thanks, Daniel!

  32. 32

    Great article although i installed the Eclipse & Android on my PC but really cant build anything special i got inspired and get a direction on how to build a application after looking at your sample demo :)

  33. 33

    Wow, this a great post….I’m interested in becoming an Android developer.

  34. 34

    Awesome tutorial. Thanks Chris!

  35. 35

    I agree too :)

  36. 36

    Just what i was looking for. Thanks a lot!

  37. 37

    Thank you very much for this! More Android stuff @ SM!

  38. 38

    Very useful article :)
    Looking fwd to more android tips

    Anoyne here knows how to connect HTC Hero 2.1 with IntelliJ Idea [windows] into debug mode? Win can`t detect phone in that mode :-/

  39. 39

    This is a really useful article, thanks

    I have used Titanium by Appcelerator ( to develop apps for Android and iPhone. It works well and is a good way to develop apps for multiple platforms. Maybe Smashing Mag can do an article on Titanium?

  40. 40

    Brilliant article, more like this please! :)

  41. 41

    Perfect, I was looking for a novice intro for Eclipse on Windows. Thanks again!

  42. 42

    Thank you man !!! Very helpfull !!!

  43. 43

    Sounds good – will keep an eye out for that! :)

  44. 44

    Oh yeah, one thing I thought might be handy to mention in your article was this

    Absolutely will drive beginners NUTS – basically it’s possible to break the ADT to a point where you have to fix it manually, the above article describes symptoms and solution :)

    Cheers again for the article!

  45. 45

    Thanks a lot for posting this tutorial, i would love to see more articles on Android development here.

  46. 46

    Thanks a lot its so helpful tutorial.

  47. 47

    tx, any chance of converting this tutorial with Netbeans???

  48. 48

    very good tutorials for starting with.
    Thanks for sharing.:D

  49. 49

    Hey Hi,

    Nice article.

    I am an amateur at Eclipse and android and I am getting this error on running your code.

    Java Model Exception: Java Model Status [gen [in BrewClock] does not exist]
    at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(
    at org.eclipse.jdt.internal.core.Openable.generateInfos(
    at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(
    at org.eclipse.jdt.internal.core.PackageFragmentRoot.getKind(
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processDelta(
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.handleAffectedChildren(
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processDelta(
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.handleAffectedChildren(
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.processDelta(
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.elementChanged(
    at org.eclipse.jdt.internal.core.DeltaProcessor$
    at org.eclipse.jdt.internal.core.DeltaProcessor.notifyListeners(
    at org.eclipse.jdt.internal.core.DeltaProcessor.firePostChangeDelta(
    at org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(
    at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(
    at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(
    at org.eclipse.core.internal.resources.Workspace.endOperation(

    It would be great if you could please help with this.



  50. 50

    Great article man! I’m dabbling in android development myself at the moment too. If you get a chance to write another article, one thing I’d really love to hear is a decent balanced argument on is whether there’s an e-commerce based future in app development. Personally, I think it’s going to be limited to games and applications rather than the whole “me too” boom that occurred with websites – the problem is that companies (in my experience) all *want* an app without stopping to think whether they *need* one. On balance I’d say that the future of mobile based e-commerce is going to be mobile optimized websites – everyone’s gonna want one of those in the next few years!

    Anyway I’ll stop rambling now. Keep up the good work dude!

  51. 51

    @Ganesh Not seen that before. A couple of things to try: When creating the new project (or importing the code into a project), be sure to choose “Android Project” in the New Project dialog.

    Also check the project is being built automatically by Eclipse (Project->Build Automatically is checked), sometimes cleaning the project files (Project->Clean…) helps.

  52. 52


    Tried both of them but no change.

    What I observed was that even for a Hello World! example it is giving this error. Need to look at my Eclipse installation.

    Thanks for the help.

    Looking forward to further articles from you.


    Ganesh Bhat.

  53. 53

    Hey Hi,

    Thanks for the help.

    Just want to add that I always get this error when I create a new project.

    Failed to load properties file for project ‘BrewClock’

    Am i missing some step here?

    Please let me know.

    Thanks Again,


  54. 54

    Great article Chris!

  55. 55

    This tutorial was very frustrating for me. I got the layout done and it works well, but then when I move on to the next part and type everything exactly as you have it, many of the things are underlined in red and it says there are errors. Also, I don’t understand the relationship between the different sets of code you have written.

    For example, when you said:

    “We’ll use those attributes to connect the Buttons and TextViews in our layout to the code:”

    What does that mean? It seems like every new code you start begins with “# /src/com/example/brewclock/ ” so that confuses me a lot, are you overwriting the code you put in previously? It seems like you are writing over the old code since it has the same line numbers (1-22). Or am I creating multiple pages of code? Please help.

  56. 56

    @Philip Regarding your “attributes connect the buttons etc..” question, you can define your layout either computationally or using XML – if you go for the latter (and, to facilitate a decent seperation of concerns it’s reccomended you do) then you need to get references to the elements from your XML in your source code if you want to perform any interactions on them. If you’re from a web background, it’s the exact same principle as defining an ID for an HTML element and then accesing it from javascript using “document.getElementByID” or “$(#element)”.

    I personally think this article is pretty good, and I really ordinarily wouldn’t do this, but I have been writing articles myself on android which cover almost the same points as this one does but go through everything a bit more slowly and in a bit more detail. Someone’s already linked to it above but here it is again.

    If linking to external articles / your own work is frowned upon by this community (don’t really post here that often) then please accept my apologies and feel free to moderate or delete this post.

    -Mikey xx

  57. 57

    Unfortunately, I am already using Eclipse Helios (J2EE developers). I installed the Android Development tools in Eclipse but when I open windows/preferences android does not appear as an option.

    So I am kind of stuck at the first hurdle :(

    Anyone any ideas – OS Linux/Ubuntu

  58. 58

    Great article :)

    Give us more like that ;)

  59. 59

    I dont want to spoil this article , but for everyone new to android and not knowing anything abouth java,or any code related, for these persons i have a verry good and fun to use program made by some google team members.
    It is called Appinventor (AI) , it is a Google Beta program what requires inventation.I’m one of the few but growing beta users.

    Anyway forget my bad englisch and take a look:

    PS:I dont work for google, i asked several times if they had a job for me but never got a response lol

    Grtzzz wHiTeHaT

  60. 60

    Hi Chris:

    Thanks for this fantastic article.
    I’ve never seen a more straight forward tutorial on anything!
    This is surely a talent in itself, which I am sure, comes from years of doing what you are passionate about!

    Hoping to see more content from you!

    Cheers and all the best for Plymouth Software!

  61. 61

    @Philip Thanks for the feedback, in future posts I’ll try to make changes to the source code easier to follow.

    I’ve started each block of code with a comment to show which file is being edited (# /src/com/example/brewclock….). You should not enter these comments into your code, they are just for reference. I do this as I’ve often found myself frustrated with tutorials and docs in the past that give you a chunk of code, but leave you guessing where to put it – especially when a project spans multiple files.

    Generally, you should not be overwriting any code, although some lines of code may change (such as “implements OnClickListener” which is added to the BrewClockActivity class declaration).

    I’ve used ellipses (…) to show where existing code should be left alone.

    It’s sometimes difficult to get a complete view of the code in a tutorial such as this, so I’d also recommend following the complete source code on github (

  62. 62

    I’ve seen other tutorials where the current code is left black, and the newly entered code for step X is colored green, deletions might be in red…

  63. 63


    I was able to get my initial app up and running following the directions, but don’t see any Hello World message. Did I miss a step? I would have expected to have written the Hello World text in the Activity class but didn’t see directions for that.


  64. 64

    Hi Cory,

    The “Hello World” message is contained in the strings.xml resource and read by the layout.xml file (I’ve copied the relevant lines below). You don’t need to write the message anywhere in your code.

    The BrewClockActivity that onCreate() method loads in and displays layout.xml (which contains the TextView). If you’re not seeing the message, check the code in your file matches below:

    <!-- strings.xml -->
    <string name="hello">Hello World, BrewClockActivity</string>
    <!-- layout.xml -->
    <TextView android:text="@string/hello" />
    // com/example/brewclock/
    package com.example.brewclock;
    import android.os.Bundle;
    public class BrewClockActivity extends Activity {
        /** Called when the activity is first created. */
        public void onCreate(Bundle savedInstanceState) {

    Hope this helps, feel free to contact me if it still doesn’t work.

  65. 65

    Thanks Ash, appreciate your comments. I’m writing the next part of this tutorial at the moment, so keep an eye out on Smashing Mag :)

  66. 66

    Hi Tam,

    I’m also using Ubuntu and ran Helios Eclipse for a while, although there were a few issues with the Android SDK.

    Although you’re running Helios, you can still download Eclipse 3.5 from, extract it to a separate folder (e.g. /opt/local/eclipse-3.5) and then run it separately from 3.6, for example by running /opt/local/eclipse-3.5/eclipse. You should then be able to follow the tutorial. Hope this helps!

  67. 67

    Thanks a lot, Chris.
    After this post I think I’ll finally start some Android development.
    I’ve completed this tutorial using IDEA and it works well too!
    I’ve noticed some mistakes (or maybe these are not mistakes in Android SDK) – you’re using == operator to check which button has been clicked. I’m not sure as it works in Android, but in Java SDK this should be better replaced with .equals() – this will guarantee the correctness. And again – I’m just thinking as Java developer – I’m not an Android developer yet and I don’t know how the == is treated in Android platforms

  68. 68

    Thanks Chris..

    All instructions were a perfect spot on…followed it step by step and it worked without a hitch…

  69. 69

    Since having my android-running HTC Legend, I always wondered how to build apps myself. Having a lot of other things to be done currently, I didn’t follow this anymore, thinking it’s a hard way to get into this coding stuff based on Android. You need to know I’m programming for long in PHP and other website languages, as well as in Java for 3 years.
    I jumped into this article randomly, and it was mindblowing! I had never thought it’s that easy (and fun) developing for Android. Thank you so much for this tutorial and keep up the great work, Cheers – Daniel.

  70. 70

    You say: “Eclipse has a graphical layout designer that lets you build the interface by ‘dragging’ and ‘dropping’ controls around the screen”

    My question is: ¿Where i can get those ‘dragging’ and ‘dropping’ controls in eclipse helios?


  71. 71

    Awesome! Thanks a lot!

  72. 72

    Thanks this article is helpful for my projects (

  73. 73

    This was really helpful! Thank you for the great tips. I hope to see more.

  74. 74

    for awhile i was lost, then i realize that i have to move on with my career… mobile app development? android or apple? I love opensource so it has to be android… i hope SM will put up an article about mobile app development.

  75. 75

    I did this tutorial, but I ended up with a different code than what’s hosted at github. Why would it be that? And my version doesn’t work properly. Has anything changed?

  76. 76

    Fernando Agüero

    April 6, 2011 2:44 am

    Great article. I wish you write a second chapter.
    Thanks ;)

  77. 77
  78. 78

    Thanks you are a good teacher.

    If i used your tutorial somewhere I will add your name and link back to this page.

  79. 79

    Thanks For such a nice tutorial. And I will wait for the coming next tutorial. I have got the correct information.

  80. 80

    Thank you man! Great article!!!

  81. 81

    Could someone email me the end result because I have a couple of errors I cannot resolve.

  82. 82

    Hi Christina,

    Once you have your project compiled well and running as expected in emulator, then you should find a ‘ .apk ‘ file in your work folder. All you have to do is transfer this file to phone. ( you could load it into the sdcard, or file transfer with bluetooth, send as an email attachment and download it to the mobile….., etc).
    Also make sure, you have checked the Unknown sources (Allow installing of non-market apps.), in settings > Application settings.

  83. 83


    i am getting the following error:

    View cannot be resolved to a type.

    Any advice???


  84. 84

    nice one for beginners

  85. 85

    I dont get it :s I made something wrong, please could someone post the full code of the file # /src/com/example/brewclock/ ??

    Thank You !

  86. 86

    I’ve been thinking about playing around with Android App building and this article will be of great help to get me started. Thanks a lot.

  87. 87

    Thnx aloot for ue great teturial,
    i want to debug my app on Galaxy tab , GT-P1000
    and my pc OS is windows

  88. 88

    hello Mr. CHRIS BLUNT

    im a student mr. chris and i have to make a thesis and i ‘m going to develop a word game with the concept of text twist but i don’t know how to start with the use of android. Sir with your kind heart will pls help me and guide me in making my game? i want to learn sir please sir teach me how. thanks alot sir..

  89. 89

    awesome! thank you.

  90. 90

    Thanks a lot,Chris.
    nice post.

  91. 91

    Hello Chris,

    Just came across your nice post.
    This may seem a bit advanced, but I am trying to use an Android tablet (MID 7″ tablet with 3G) with eclipse (instead of using the emulator, I want to use the actual device). However I am facing problem connecting the tablet to my desktop pc. I searched quite a lot on google but could not get the exact fix. I would be glad if you could help me in this regard.

    Thanks in advance.

  92. 92

    I am following your Tutorial, because for me it seems to be the best broken down as you explain the different aspects and I believe that this is the way to learn effectively, I am having an issue with the following code from your list above:

    12 // Setup ClickListeners
    13 brewAddTime.setOnClickListener(this);
    14 brewDecreaseTime.setOnClickListener(this);
    15 startBrew.setOnClickListener(this);

    I am using Eclipse and attempting to type it out so as not to copy and paste and this way get myself accustomed to typing out the command and the above lines shows as an error and Eclipse corrects it as the following:

    brewAddTime.setOnClickListener((OnClickListener) this);
    brewDecreaseTime.setOnClickListener((OnClickListener) this);
    startBrew.setOnClickListener((OnClickListener) this);
    Iam wondering if I am doing something wrong or just missing something. Could you assist me on this.



  93. 93

    It’s a nice post. mainly you have added the questions and concerns people come up with when they look and Android market and think of Android Game Development .

  94. 94

    Hey mate… love your artickel.. but when try to build it.. i keep having problems with
    brewCountDownTimer = new CountDownTimer (brewTime * 60 * 1000, 1000);

    it says Cannot instantiate the type CountDoWnTimer???

    Any Ideas?? im pretty lost, i dont understand the problem

  95. 95

    @Jacob K
    import android.os.CountDownTimer;
    Eclipse : Ctrl+shift+o

  96. 96

    thank you so much for a very well explained tutorial.fortunately i didn’t get serious error except on warning on this part:(findViewById( but it’s gone when i modified the strings.xml based on your code.i just learned a lot from this’re a blessing..thank you so much!

  97. 97

    ecliepes software works in windows xp 32bit?

  98. 98

    thanks a lot for the info
    one query i already downloaded SDK and NDK and ADT how i connect with eclipse and
    i am student if u have more example project please send to my mail adds
    thanks in advance

  99. 99

    it’s good..

  100. 100

    It’s hard to find knowledgeable people about this subject, but you sound like you know what you’re talking about! Thanks

  101. 101

    I followed the BrewClock Code and layout xml . on running it, i am getting an error message.
    The application BrewClock
    (process com.example.brewclock) has stopped
    unexpectedly.Plese try again.
    and it is showing Force Close button.

    what might be the reason? I doublechecked bot code and xml, and they are ok. one major issue I encountered and changed by following eclipse quick fix was
    the event listening.

    // your plan of Setup ClickListeners

    eclipse changed to this

    brewAddTime.setOnClickListener((OnClickListener) this);
    brewDecreaseTime.setOnClickListener((OnClickListener) this);
    startBrew.setOnClickListener((OnClickListener) this);

    and finally ai got that error.

  102. 102
  103. 103

    These features are useful in eclipse galileo version but not in eclipse because whenver i tried to make button in eclipse it tries to find some string source and when i write it like (“@string/abc”) , in place of abc ,,when i write anything which i like to show on user interface , then at that time this string keyword also shows,,i dont know how to remove that..????

  104. 104

    not in eclipse classic,,sorry i forgot to mention..

  105. 105

    Thank you for best Tutorial!!

  106. 106

    Good tutorial for beginners like me. But I need more tuts

  107. 107

    Hello, good tutorial but i got some problems, please could you make some changes on it if possible?

    ADT 21.1.0 (February 2013)
    Dependencies (since december 2011):
    Java 1.6 or higher is required for ADT 21.1.0.
    Eclipse Helios (Version 3.6.2) or higher is required for ADT 21.1.0.


  108. 108

    i am using linux mint os.eclipse support linux mint…

  109. 109

    I am having trouble with the part. do you think you could either post/send the full code for it to help me figure it out

  110. 110

    hey man , i just wanna ask a question . i’m a totally beginner in programming . i just copied the codes you wrote there and i’m having an error with this “setContentView(R.layout.main);” , help me please .
    anyway nice post . tnx in advance . ^_^

  111. 111

    I start to develop an Android application, but now, when I start Eclipse I find a new environment : ANDROID DEVELPER TOOLS with the name ADT, but with the same Eclipse icon . Please help me to comeback to my first Eclipse.
    thank you.

  112. 112

    I really enjoyed the quality information you offer to android beginners from this blog. Thanks for sharing such a useful guide on android app development using eclipse.

  113. 113

    Could you email me the end result of the brewclockactivity then?

↑ Back to top