Volleynerd Knowledge Base

Wednesday, January 06, 2010

First Droid App


WHEW - had a hell of a time today during IK RECESS building my first app for the Droid. Just some notes on what I had to do:

Started here with SDK install. Which has a bunch of sub-steps.

Download Eclipse, wait, need Java -- what version, and what type (EE, SE, ME)? version 6 JDK most recent, fine.

Install Java, which also installs something like "update 17".

Install and Run eclipse. Nope. Doesn't find a java VM. Try -vm command line arg to show it where the VM is. Nope. Now doesn't barf, but just runs, and process dies after 5 secs (no UI). Eclipse readme says compatible with Java 1.4.2. WHAT? I'm using Java 6. Go to get old version, maybe uninstall 6 and use 1.4.2? Huge red warning before download 1.4.2 --- it has passed it's "EOSL" (end of service liftetime) - back in Oct 2008. Nice.

Coworker Brad says screw all that - use NetBeans.

Nice - NetBeans install comes with Java (if needed), but recognizes that I have v6 patch 17 or whatever already and uses that.

NetBeans IDE starts up! But ... not so fast. Move on to step 2: Android SDK

Extract Android SDK, and try to run "SDK Setup" but it doesn't seem to do anything.
Readme says an alternative is command line:
tools\android.bat update sdk


Whew - runs a UI that goes out and finds packages. Fails on https calls (expired cert? who knows - no detailed error message). Set to use HTTP instead. Get a huge ass list of packages, now we're getting somewhere. Chose them all (shouldn't have) and download. Takes *forever*.

Sweet! Now we have some sub-folders under the SDK "platforms" folder that was initially empty. One for each of the Android OS levels, 1.5, 1.6, 2.0, 2.0.1

Next step: ADT plugin

ADT plugin is for Eclipse, so we use nbandroid.
Loose instructions here.

To install the Android platform within Netbeans though, we need to point it to a "platform" folder. Now we have one of those after getting through the Android SDK components updater above. Point at the 2.0.1 platform folder.

Woot! Platform installed. Create new project. Hello world. Run!
... wait ... need an emulator.

Per Google instructions, use command line tool to create one.
tools\android.bat create avd --target 5 --name dan_droid

What is "5" ? It's the OS version target dummy. Use the following to see the choices:
tools\android.bat list targets

OK, created the emulator. Back in NetBeans, Run! Sweet, choose emulator ("AVD") to start. Go.
... damn ... errors in the output window that emulator is not ready.

Poke around the tubes and find that you should start the emulator first. (not let the NetBeans IDE start it)

Manually start the emulator
\tools\emulator -avd dan_droid
(dan_droid is the name of the emulator created from above)

Ahh, there's a UI to manipulate the emulators too.
\tools\android.bat
"Virtual devices" node

WOOT! After letting the emulator start and settle down, now run from NetBeans IDE -- I see my "hello world" !!

In NetBeans, when debugging, to prevent getting prompted for which emulator device to use each time:
Project, Properties, Run node.
Set Target Device = "automatic", and select the AVD from the list
(dont worry that this is the registered one whereas you want it to use the currently running one, it seems to figure that out)



Comments: Post a Comment

Home