On Metacritic: BioShock 2: The reviews are in
BNET Business Network:
BNET
TechRepublic
ZDNet

December 16th, 2007

Getting started with Android

Posted by Ed Burnette @ 5:43 pm

Categories: Android, Eclipse, General, Google, Java, Programming

Tags: Google Inc., SDK, Eclipse, Plug-in, Android, Java Development Tools, Open Source, Development Tools, Software Development, Software/Web Development

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.

Ed BurnetteEd Burnette is a professional developer and author of several articles and books about computing including Hello, Android: Introducing Google's Mobile Development Platform, 2nd Edition. For disclosure of Ed's industry affiliations, click here or to view his full profile click here.

Email Ed Burnette

Subscribe to Dev Connection via Email alerts or RSS.

Related Discussions on TechRepublic

Did you know you can take part in these discussions with your ZDNet membership?

  • Talkback
  • Most Recent of 20 Talkback(s)
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... (Read the rest)
Posted by: Ed Burnette Posted on: 12/18/07 You are currently: a Guest | | Terms of Use
Wicked coOL Ed!  D-T-Schmitz | 12/16/07
RE: Getting started with Android  pizak | 12/17/07
RE: Getting started with Android  pizak | 12/17/07
Is that true?  No_Ax_to_Grind | 12/17/07
Power to the People  Counselorleo | 12/17/07
sipping the kool-aide?  balsover | 12/17/07
Sorry but the people don' t have cell towers  No_Ax_to_Grind | 12/17/07
Actually anything that complies with the phone standard would work  balsover | 12/17/07
Sort of...  No_Ax_to_Grind | 12/18/07
Isn't this putting the cart before the horse?  balsover | 12/17/07
Clearing up some things  Ed BurnetteZDNet Moderator | 12/18/07
Know more about MS  balsover | 12/18/07
No jitted code  Ed BurnetteZDNet Moderator | 12/18/07
RE: Getting started with Android  nydas | 12/17/07
To the naysayers....  techboy_z | 12/17/07
the overhead would be a problem in a cell phone  balsover | 12/17/07
Yep  dimonWar | 12/17/07
Actually, it's a replacement  Ed BurnetteZDNet Moderator | 12/18/07
GAP - Just another platform  Heatlesssun1 | 12/17/07
RE: Getting started with Android  corifeanu@... | 12/18/07

What do you think?

SponsoredWhite Papers, Webcasts, and Downloads

advertisement

Recent Entries

Archives

Favorite Links

ZDNet Blogs

White Papers, Webcasts, and Downloads

SmartPlanet

Click Here