Random header image... Refresh for more!

Summarizing Android

So far, my experience with Android has been brief moments of totally awesome brilliance, separated by vast swaths of WTF.

For example, why is it easier to get a speech synthesizer integrated into my application than it is to get a context menu set up?  Why is the debugger so introverted that it refuses to tell me what’s wrong?  W…h…y… …i…s… …i…t… …s…o… …s…l…o…w… …t…o… …t…y…p…e… …a…n…y…t…h…i…n…g… …i…n… …t…h…e… …e…m…u…l…a…t…o…r…?…

I understand that writing a single application meant to run on multiple different highly contstrained environments is complicated.  I understand that defining a View in XML and interacting with compiled code classes is complicated.

But Microsoft’s done it and has done it for years.  I set some things in a XAML file and it’s just there in the class.  I don’t have to use a TextBox Resource ID to look up an element I need to work with.  And I doubt they’re the first or the only that can do it.  Why can’t the flagship open source IDE figure that out?

I’m hoping that I’m just missing something.

Whatever.  At least it’s still not Objective C.

December 11, 2010   No Comments

Hang around.

I just love programming in E…

clipse.

December 11, 2010   No Comments

Getting my WYSIWYG on.

December 11, 2010   No Comments

Scrambled Keys

F5.

F5.

F5 F5 F5.

WTF?

Why isn’t this running?

F5 F5.

Grrr…

Run->Debug.

(wait)

(wait)

F10.

F10.

Why is that making the File menu highlight?

F10.

F11.

WTF?!  It restarted?

Tip of the day:  If you install the C/C++ Developer Tools in Eclipse, it’ll come with a set of Visual Studio key bindings.

December 7, 2010   1 Comment

Spot the Problem

My application has crashed.  Can you spot the error?

Of course you can’t, because instead of popping up with a very visible “You had an exception!” dialog, the error is playing hide and seek.

It’s actually there, in two places (That I’ve found…).

  1. In the Variables pane, “e” is a RuntimeException.
  2. In the log pane, if you scroll up about a hundred lines, you’ll find the same RuntimeException, although all of the useful bits are truncated.

The exception I’m getting is that I didn’t put an android:layout_width attribute on a checkbox element that I’ve added.

December 6, 2010   No Comments

But I Don’t Wanna Install Eclipse…!

Last week, I got an Android phone, the Droid X.  I want to try developing on it, because I have a few ideas for programs I’d like to have in my pocket all the time.  Ideally, I’d do it all in a “Crazy Weekend Project” format, unfortunately, I don’t seem to have to ability to dedicate five days in a row toward a single goal right now. 1  I do, however, have bits and pieces of time here and there that I can use.  I know that if I don’t force myself to get started on something, I never will. 

Just ask that Mac Mini I bought in April in order to try iPhone/iPod development.  It’s still sitting unused in its box, waiting for a Crazy Weekend Project that’ll probably never come. 2

So, here I am, just getting started and making it happen.

But…  I don’t wanna install Eclipse!

You can’t make me!

Please…  Please don’t.

Ah crap.

I had to use Eclipse at work years ago.  It could charitably be described as “broken” on a good day.  Now, to be fair, I’m not sure where the brokenness came from, whether the program was just bad or if it was a side effect of the fact that my installation was a directory copy from a co-worker’s machine.  Either way, it didn’t work.  At one point I tried switching projects and it freaked out and lost the entire concept of packages.  It took me two hours before I was even able to convince it that it understood Java code.  I also remember searching being extraordinarily painful, but I don’t know why.

On the other hand, at least I won’t have to write Objective C.

Yes. I own a copy of NeXTstep. nerdScore++;

It’s not just Eclipse.  It’s JDKs, JREs, AVDs, SDKs, ADKs, MREs and STDs.  The quick start here has pointers to the stuff you’ll need:  http://developer.android.com/sdk/index.html

Of course, it’s open source documentation which is usually awesome in the way it leaves out important information and glosses over critical steps.

Step 1: Easy.

Step 2: Easy.

Step 3: WTF?

The quick start goes very sideways here at step 3.  It tells you to “set up a remote update site”.  Which would probably be easy, if such a thing existed.  But it doesn’t.  You can look through all of the menus and property items in Eclipse, but it’s not there.  What they mean by “remote update site” is that you should go to “Help->Install New Software…” and put that URL in there.  After that, make sure the box next to “Developer Tools” is checked and go through the wizard to download and install those packages.  Once that’s done, go to “Window->Preferences…->Android” and set the SDK path.

Step 4 is also a bit on the wonky side, but with enough fiddling, you’ll probably get it sorted out.  You see, even though you just spent twenty minutes installing and configuring Android SDKs, you still don’t actually have the SDK for any of the Android platforms.  You still have to download and install those packages, too.  To do that, go to “Window->Android SDK and AVD Manager”, then select “Available Packages”.  You should have a tree that you can expand and see various packages that you can download.  At a bare minimum, you’ll need to pick one of the “SDK Platform Android” versions, probably either the latest one or the one that matches your device.  I think the Google APIs are needed for maps and some of the other Google tools, but I haven’t played around with any of those yet.

Now you’re probably ready to go.  You should be able to create a new Android project.  I have no idea what any of the fields on the wizard are, so I’m not going to bother attempting to explain them because I’d probably be wrong.

Once I created the project, I immediately got an error about R.java not being found, even though a quick check through the package manager showed that it’s there. 3  A Project->Clean… took care of the problem for me, and then I was able to build4 and run the sample project.

Well, at least, that’s what you’d expect to have happen, but nope.  See, there’s no Android Devices to run it on. 5  You have to set up an emulator AVD before you can begin.  Go back to the SDK and AVD manager and click “New”.  That’ll pop up a dialog where you can give it a name and specs.  Several warnings:

  1. The Name can’t have spaces.
  2. It appears to pre-allocate the SD card file, so don’t create a 16384 MB (Sorry, MiB…) SD card like I tried to do, or the process will kick off “mksdcard.exe” which will take forever and fill up your hard drive.  I went with 256MB.  I know know if that’s too small, but whatever, I’ll find out later.
  3. Under hardware, you’ll want to enable some of the hardware bits you might want to develop against, although I’m not quite sure yet just how exactly the emulated GPS or accelerometers are supposed to work…
  4. No, I have no idea what in the hell “Abstracted LCD Density” means.

After you hit “Create AVD”, it’ll churn for a bit and give you an emulator image you can use.  And, of course, nothing has changed since my days on the Windows CE team6:  Mobile Device Emulators are slow.  Really really freaking slow.  It’s usually faster to use a physical device, if you dare.

After a very long boot process…

…your program will run and do this:

Well, it looks like I’m off to a good start! 7  Can’t wait to see what’s next!

(As this isn’t a Crazy Weekend Project, don’t expect frequent updates.  In fact, don’t expect any updates at all, that way if I’m distracted by Shiny Things™ and never come back to this, you won’t be waiting around forever…)

By the way, while you’re in the emulator, play around and you’ll find interesting things.  Like this:

I NEED THIS ON MY PHONE!

  1. Half of it is the after effects of moving to a new house earlier this year, the other half are called the Wii and the XBox360 and my general video game obsession. []
  2. After all, there’s no Haggle to write a Haggle app for anymore… []
  3. Looks like it might be Eclipse that’s broken after all… []
  4. No CTRL-SHIFT-B!  ARGH! []
  5. Never mind that it would probably be fairly easy to include a reference device or two, this is Open Source, why do anything for the user if the user can ./configure, make, make install and make configure it for themselves? []
  6. Platform Builder test team, WinCE 5.0 and Windows Mobile 5, 2003-2004, mostly focused on the CE emulator integration []
  7. BTW, I don’t actually have any idea what I’m doing, so if you’re looking for help, you’re probably in the wrong place…  Don’t try any of this at home without getting a second opinion first. []

December 5, 2010   No Comments