Android – Eclipse Quick Start

Apr 10, 2009   //   by Bill Tarr   //   Blog  //  No Comments

Setting Up Your Environment

Getting Android running on Eclipse is easy, but the documentation was pretty dispersed. Here is a quick start based on my experience on Vista.

Download Eclipse. I’m using eclipse-jee-ganymede-SR1-win32, I already had the J2EE version installed, I imagine you could use any the regular Java version.

Install the ADT plugin, the directions on the Android site are fine. You should also download the Android SDK. I am using android-sdk-windows-1.1_r1, so check the current version to see if anything has changed.

There are a few interesting things in the SDK:

\tools Directory

These are the command line tools that you won’t be needed TOO much. Most of the things you can do in the command line are better performed in the DDMS perspective in Eclipse (more on that shortly!)

One thing that I’ve already needed the command line for is creating an sdcard. You’ll need one if you want to use the camera or record any media on the emulator. The beginning of this tutorial on Camera Capture describes the the process pretty well. All I had to do was add an sdcard into the spot where Android stores it’s user data on Vista, like this:

C:\…\android-sdk-windows-1.1_r1\tools> mksdcard 1024M C:\Users\<USER_NAME>\AppData\Local\Android\SDK-1.1\sdcard.img

\samples directory

Full of useful code that will get you started. Personally I thought the NotePad application was a great starter app (if visually boring), using a couple activities linked together and SQLite. If you just want open one of these apps, use the steps under Creating an Android Project in the Eclipse with ADT setup guide.

Let’s Start Coding!

Well, you have everything you need, lets jump in and see how it works. The Hello World Tutorial on the Android site is fine. Go ahead and follow the steps to create a new Android application. It will auto-create some code for you. Jump down to the section Run the Code: Hello Android and you’ll setup the run configuration. Once you have the emulator running, go ahead and look through the remaining tutorial, it will teach you a little bit about coding in Android. Stop at Debugging Your Project though, and lets look at some useful tools.

DDMS (Davlik Debug Monitor Service)

This is a good time to dig into the a tool that will really enable you to develop to the emulator. It runs as a perspective within Eclipse, so lets open it now, and switch to that perspective.

I don’t want to get too bogged down in the details of this screen. The most important detail for you right now is the LogCat. This is where you can view all the errors you would be coding if you were me.

LogCat isn’t too complication. You can set the debug level – (V) is Verbose, (D) is debug – here, or under Windows -> Preferences -> Android -> DDMS *NOTE – You can also see the ADB Debugger Port in that menu, we’ll be using that shortly.

One further note on LogCat. A couple times the logging seemed to stop when I started using LogCat, especially if ADB.exe process stopped, or I had to restart the Emulator. When this happened, I found selecting my application under the Devices tab seemed to work. Give it a try if your logging stops.

Breakpoint Debugging

Alright, last topic. I’m pushing the limits of “quick start” already!

If you’ve been a software developer sometime in the last decade, you expect to be able to step through your code. You can with Android, but the setup is a little different from other Eclipse projects… Here is a good Eclipse setup guide that has an excellent section describing Debugging the emulator with Eclipse.

My only issue was the port my debugger was sitting on was different, so make sure to check Windows -> Preferences -> Android -> DDMS and check the ADB Debugger Port.

I believe you need to set breakpoints, before launching the app. If you have a breakpoint set like this:

When your application hits that code, Eclipse will automatically prompt you to switch to the Debug perspective. Let it switch, and you will be able to step through your code.

You should have enough to begin work in Eclipse. Good Luck!

Leave a comment

(will not be published)

CAPTCHA Image
*

Recent Posts