Getting started with Android

Getting started with Android

Summary: In a couple of years, Android is expected to be powering millions of cell phones, making it a major platform for application developers. Whether you're a hobbyist or a professional programmer, whether you're doing it for fun or competing for the Google $10 million developer prize, it's time to learn more about developing for Android. This article will help you get started.


Getting started with AndroidAndroid is the new mobile phone SDK created by Google and the Open Handset Alliance. In a couple of years, it's expected to be powering millions of cell phones, making Android a major platform for application developers. Whether you're a hobbyist or a professional programmer, whether you're doing it for fun or competing for the Google $10 million developer prize, it's time to learn more about developing for Android. This article will help you get started.

[ Read: More coverage of Android ]

Installing First you need a copy of Java. All the Android development tools require it, and programs you write will be using the Java language. JDK 5 or 6 is required. It's not enough to just have a run-time environment (JRE); you need the full development kit.

Next, download the latest Android SDK from Google. The Android download page has packages for Windows, Mac OSX, and Linux. After downloading the SDK, unpack the .zip file to a suitable location (for example C:\Google). By default the SDK will be unpacked into a subdirectory like android_sdk_windows_m3-rc37a. This is your SDK install directory; make a note of the full path so you can refer to it later.

To make development easier, Google has written a plug-in for Eclipse called the Android Development Tools (ADT). To use it, you need to have Eclipse 3.2 or later. Get the Eclipse IDE for Java or Java EE Developers, or the Eclipse Classic (SDK) package from the Eclipse download page if you don't already have it. Then start Eclipse and use the Update Manager to install the Android plug-in. Restart Eclipse, and update your Android preferences (Window > Preferences > Android) to point to the SDK install directory.

Note: Plug-ins for IDEs other than Eclipse are in the works so if you can't use Eclipse, keep an eye out for them at your IDE's community site. Since Eclipse support is the most mature, and it's used by the Google developers themselves, the rest of this article will assume you are using Eclipse and the ADT plug-in.

Once everything is installed it's time to write your first program.

Hello, Android Select File > New > Project to open the New Project dialog. Then select Android > Android Project and click Next. Enter the following information:

Project name: HelloAndroid Package name: org.example.hello Activity name: Hello Application name: Hello, Android

when you're done it should look something like this:

New Android Project

Click Finish. The Android plug-in will create the project and fill it in with some default files. Eclipse will take care of building and packaging it up. All that's left is to try running it.

In the Package Explorer, right-click on the HelloAndroid project, and select Run As > Android Application. The Android Emulator window will start up and boot the Android operating system. The first time you do this it will take a while, so be patient. After about 30 seconds or so, your program will be launched and you should see it running in the emulator:

Android Emulator

Just to prove we can, let's change the text displayed in this application. Leave the emulator window up and go back to Eclipse.

The user interface for Android programs is normally described in text files very similar to HTML. Under the res/layout directory, double-click on main.xml. Find where it says "Hello World, Hello" and change it to say "@string/greeting". This is a reference to a string resource that doesn't exist yet. To define it, double-click on res/values/strings.xml and add this line:

<string name="greeting">Android rocks!</string>

Now save all the files (Ctrl+Shift+S) and re-run the program (Ctrl+F11). In a couple of seconds, the Emulator screen will refresh and show the new text you entered.

Emulator showing new text

Note: You may notice something wrong with the exclamation point as displayed in the emulator. I'm sure little problems like that will be worked out soon. This is, after all, pre-release software.

Next steps The Android SDK comes with hundreds of classes you can use for telephony, animation, music, video, networking, geo-location, and more. Google provides extensive documentation and reference information on their web site, and a number of sample applications are included with the SDK. There is also a FAQ and a forum especially for beginners.

But before delving into that, I recommend you take half an hour to watch a few videos from the Android Developers Channel on YouTube. In particular, there's a 3-part series of educational videos by Mike Cleron (technical lead for Android) that should not be missed. Once you grasp the basic concepts like Intents and Activities, the rest will be much easier to understand.

Topics: Open Source, Android, Google, Software Development

Ed Burnette

About Ed Burnette

Ed Burnette is a software industry veteran with more than 25 years of experience as a programmer, author, and speaker. He has written numerous technical articles and books, most recently "Hello, Android: Introducing Google's Mobile Development Platform" from the Pragmatic Programmers.

Kick off your day with ZDNet's daily email newsletter. It's the freshest tech news and opinion, served hot. Get it.


Log in or register to join the discussion
  • Wicked coOL Ed!

    D T Schmitz
  • RE: Getting started with Android

    found some step by step tutorial at
  • RE: Getting started with Android

    If you want the skinny on Android I suggest you subscribe to Dims' blog and take a look at the previous entries:

    He's the man who's had the first public apps running
  • Is that true?

    "In a couple of years, it???s expected to be powering millions of cell phones..."

    Umm, who expects that? Everything I see indicates very few of the current players want anything to do with it.
    • Power to the People

      If programmers code, and people like, companies will be compelled to:
      1. Use android
      2. Give user the equivalent on their own terms, bypassing the need for android sdk

      I suppose they will choose the cheaper way: use android, and let developers develop things for their devices, and charge for service, like the have always done.

      The "player" that does not evolve into this, will be left behind by the ones that do. All the "players" better develop business models for open source mobile.
      • sipping the kool-aide?

        If you think for one moment that cell phone providers are compelled to follow the whims of programmers then you really have been sipping the kool-aide, what you desire is the least of their concerns. What makes you think that programmers dictate what goes on a cell phone? The bean counters and marketing people are the ones that dictate what runs on the cell phone. Most people are not geeks, they are no more likely or able for that matter to install Android on their cell phone than they are likely to read man pages and go web surfing to find a device driver that will run their printer or recompile their kernel.
      • Sorry but the people don' t have cell towers

        Doesn't matter a bit what can be done to the cell phone if there is no network to support it. I don't see any major carrier saying, "sure, come in and destroy our business model while using our backbone, switch gear, routers, and cell towers to do it".

        Now if "the people" are willing to invest a few hundred billion dollars in the next few years you may be right, but I wouldn't hold my breath waiting for it to happen.
        • Actually anything that complies with the phone standard would work

          That is why I don't need a t-mobile phone on the t-mobile network, as long as I have a t-mobile sim card and my phone supports the correct frequency my GSM phone will work on the t-mobile network just as my t-mobile phone works without problems in Europe.
          • Sort of...

            But you still only get the "services" the carrier provides and each of them will of course carry a fee. The idea that any of the carriers are going to allow people "all you can eat" or every goofy thing the coders comes up with is silly.
  • Isn't this putting the cart before the horse?

    >In a couple of years, it?s expected to be powering millions of cell phones, making Android a major platform for application developers.

    Having Google's name on something doesn't automatically guarantee the success of a project, not everything that they touch turns to gold. There are a couple of facts that Google has no control over.

    Java is an interpreted language and as such adds overhead to the start up and running of an application. Unlike desktop apps a cell phone doesn?t generally keep the jit?d image in ram so if memory gets tight as it usually does on a cell phone the environment dumps the jit?d code requiring it to be recompiled the next time that code is called. It is possible to purchase a phone that has more CPU cycles and more ram directly from the cell phone manufacturer, but generally speaking (at least in the US) the cell phone provider is the one that dictates how much ram and how fast the installed CPU is and they generally go on the cheap to increase their profit margins leaving you with a dog for performance. Java on a cell phone is a dog and MS Mobile is no better if you use .NET to create your applications. Sun may believe that Java is the ideal tool for low power embedded applications, but what would you expect from a company that does it?s development on multi processor RISC workstations?

    Second of all the current cool cell phones do not run on Java, most cell phone companies are concerned about creating an iPhone killer and that is not Android. Unless iPhone (or however has the current coolest cell phone) runs Android I don?t expect the other cell phone companies to care.

    There has (or at least there was) a Linux platform for creating cell phones and I don?t see that taking the world by storm, why should Android expect to do any better? At least the Linux platform would have run better on less resources than Android.
    • Clearing up some things

      First of all, Java is not an interpreted language, although its implementation in Dalvik is.

      Google has put a lot of thought into running apps on small devices. If you watch the videos, the whole system they have of saving frozen states ("Icicles") and killing unimportant programs looks great. Unlike the Microsoft mobile stack, the user will never have to worry about stopping applications, and the difference between "Hide" and "Close" and "Exit". That always drove me nuts on my iPaq and it's solved on the gPhone.

      Android is built on a Linux foundation so it can use Linux device drivers, process and memory management, etc..

      If you read nothing else about Android read these two pages. They'll help clear up some of your misunderstandings.
      Ed Burnette
      • Know more about MS

        I do not beleive that I misunderstood anything, although I was incorrect to say that Java was an intepreted language and I knew better, it was just a slip on my part.

        You didn't not understand what I said. The garbage collector on Android will discard jitted portions of running programs under tight memory contraints and on a cell phone/PDA that happens quite often, that has nothing to do with killing applications because the application itself doesnt get killed. So, as you are running your gPhone and memory gets tight Android deletes a jitted portion, does not swap the compiled portion to flash and then your app calls that portion again, forcing it to get re-jitted and that can quickly add a lot of CPU overhead to your gPhone. The same thing happens in Windows Mobile.NET. The advantage of Java and .NET code running on a PDA is that the p-code produced by the compiler takes up less flash space than a native code app, but it is not nearly as effiecent as a native code app.

        There is nothing special regaring the Linux foundation and it certainly is *not* a silver bullet. To the end user there is absolutely no advantage of Linux over MS PPC. Do you think that my father or any of his friends are going to care that you can use a Linux driver on his cell phone? No, he cares that he can make and receive a call. And then there is the issue of finding a Linux device driver, you write that as if it is a given and nothing could be farther than the truth. Although I have been a MS developer in past I am currently working as an embedded engineer using Linux on a network device and even getting some of the drivers that we received from MontaVista to work can be a lession in fustration.
        • No jitted code

          As far as I can tell, the current version of Android does not JIT (just-in-time compile) code, so there is no delay to re-JIT code if an application's process is terminated to make room for something more important.

          Also in a podcast, the engineers said it took 200-300 milliseconds to bring back an application that had been "swapped out" in this manner.
          Ed Burnette
  • RE: Getting started with Android

    Very informative and thorough
    • To the naysayers....

      Java is already running on most newer mobiles these days. If I understand correctly...Android is *not* another runtime that is needed, and which you are worrying about whether the handset makers or mobile providers will go along with putting on their is an SDK...which makes it easy to develop mobile apps for Java...which is already on most phones.

      Also...there's already an infrastructure in place (on all leading carriers) for downloading mobile apps on a fee basis, either per use, or for a one-time charge.

      It strikes me that the infrastructure is already there in both these aspects, and that this is therefore, simply a toolkit that implements a more uniform standard for mobile apps. Given all is a very low-risk proposition, that very well could open the floodgates. Very compelling and exciting, actually.
      • the overhead would be a problem in a cell phone

        Unlike desktop apps when the entire application doesnt get compiled and if you run into low memory situations the environment starts discarding the code that has been jit'd requiring it to be jit'd again the next time that it is called, that is a lot of cr*p for the average 200-300 MHZ cell phone CPU to wade through. You would be better off with the API designed around a Linux C/C++ toolkit than messing around with p-code.
        • Yep

          That's the real problem with android right now. Google wanted to target a broader range of developers and incite rapid development by putting java in an SDK running on a dalvik VM. However, many apps require low level access to function in an acceptable speed interval. I heard that there was already a succesful cross-compile of many C apps to the emulator, but Google needs to go further and open up a bit more the OS.
      • Actually, it's a replacement

        Android will not run on any current phone, Java-based or otherwise (I'm not counting hacks, I mean officially run). It's a ground-up redesign of the entire software stack starting just above the hardware. However, because it uses Linux, and is designed to fit into current technological limits (memory, etc.) it won't take phone manufacturers a huge amount of effort to port it to their phones and flash it into future models. I've seen pictures of two already, and it's likely all the OHA members have had projects underway for some time.
        Ed Burnette
  • GAP - Just another platform

    When Apple and Google lauch or anounce a product, its amazes me just how much hype it gets, deserved or not.

    The iPhone is slick, but at the same time, lacks real 3G broadband capabilities, so that great Safari browser is useless without a WiFi hot spot, not exactly revolutionary. Many desktop web sites work better with a Windows Mobile device using a good high speed network from Sprint or Verizon.

    And Anrdoid looks like Windows Mobile from the stuff I've seen, in fact it will probably end up running on the same hardware as Windows Mobile devices.

    Google obviously wants a piece of the mobile software and services market, as that's going to grow faster than just about anything else for the forseeable future, but to be honest, there's a lot less innovation going on here than is widely advertised.

    Blackberry's, Palm's and Windows Mobile devices have had the functionality of the iPhone and Android for years, though not as polished. That will change. In fact what may be coming down the road will be deskphones, devices that run desktop OS'es with some type of mini-screen functionality that can be docked to a monitor and keyboard and work like a docked laptop.

    There are already devices in place like this. The bottom line, the mobile market will be large array of all types of platforms, devices, form factors and concepts. Not even Google will dominate it, there will simply be too many options.

    I will play with this though, looks to be very similar to Visual Studio development for Windows Mobile. Eventually, Andriod will run .NET, and Windows Mobile has Java hacks already.
  • RE: Getting started with Android

    That's really great. However many of us will enjoy going out or reading a book. It's still a wonderful world out there.

    linux/unix admin,network designer, web developer, database admin.... ccna, mcse, mcdba...and more