Monday 27 June 2011

Microsoft Press free eBooks

I recently bumped into some free eBooks from Microsoft Press covering these subjects:

Oxfam Trailwalker 2011 Training Update 2

Ok, so we’re nearly there.

The Blood Sweat & Beers team has just completed the last of its big training sessions for the Oxfam Trailwalker 2011 endurance walk challenge on July 16th and 17th. We are now in ‘taper time’, keeping active, but doing no more big training sessions.

We will be attempting to walk 100 km (or 62.5 miles) in a little over 24 hours in order to raise funds for Oxfam’s poverty relief work and to support ex-Gurkhas. A while back we set our fundraising goal to be £2000, which delightfully has been met through generous donations, but we are still looking to improve on the total and will appreciate any additional sponsorships.

This post is the final pre-event update to show how our training has come along as we prepared for the big weekend.

Friday 24 June 2011

“Project Cooper” Mandelbrot set calculation

I’ve had a couple of people ask me on separate occasions to show some “Project Cooper” code. I’ve not posted any thus far, as the product is quite early in its beta cycle and very few people have access to it. When it has matured and is in more hands I have plans to write lots more on the subject, but since I’ve been asked, I thought I’d post a simple project.

The ever-popular Mandelbrot set is the subject of this little demo, and it’s just a simple console application, completely bypassing the Android support, just building an app that runs on the Java VM.

Thursday 23 June 2011

A dictionary of new words (kind of)

English is a massive language. The Oxford English Dictionary, Second Edition has about 600,000 words in it and that doesn't include the similar number of technical and scientific terms that aren't listed.

In the early days of the language's evolution the mass of words was helped along by England having an influx of peoples and languages from many lands and this helped grow the number of different terms for the very same thing.

Tuesday 21 June 2011

Podcast on “Project Cooper”

I recorded a podcast recently for RemObjects, and was interviewed by their technical evangelist Jim McKeeth. We talked about various things including Java, .NET, Mono and Mono for Android, but the chat was mostly focused on “Project Cooper”.

You can find the podcast on the RemObjects Radio site.

Saturday 11 June 2011

Fun & games with OpenGL on Android

I've been working up some demos for Project Cooper to show it working well with the Java class libraries and with the Android SDK. Most recently been trying my hand at getting some OpenGL demos going. I've briefly bumped into OpenGL over the years, but have by no means become a dab hand at navigating the mass of calls in the library and so have been finding the OpenGL documentation invaluable. To help me get something working I've been following steps in books and looking at demos found online.

One demo in a book I have involves a spinning cube (a popular type of demo), that has an image used to texture each side of the cube, and also makes the cube transparent. It's a nice looking demo for sure. I cobbled the code into a Project Cooper application and tested it out and was left very puzzled. You see, the demo ran just fine on the Android emulator. But on my shiny HTC Desire the cube had no bitmap texture on it - the cube was bare!

So the challenge was to find out why a well-performing physical Android device was beaten by the meagre emulator. The solution was found using logging, documentation, the Android source and some general web searching.

Wednesday 8 June 2011

Decompiling Android package resources

Sometimes you see a screen in an Android app and you think to yourself: "I wonder how that layout was achieved..."

An initial thought, especially once you realise that .apk files are just ZIP archives, is to just pull the layout xml file out and take a peek. Alas this thought gets you not very far at all as the .apk has the constituent files encoded or tokenised or somehow made unreadable and unusable.

It turns out that apktool is the answer here as it can unpack the resources and decode them into original format so you can browse the layout (as well as the other packed resouces).

Don't forget to read the "Installation for noobs" section - I missed that to start witha and so got stuck for a while. However I'd put the two downloads into a a dedicated directory on the path, rather than the Windows directory, but that's a personal choice.

Delphi Certification is back

It's been a long time, but Delphi certification has returned for those who want to prove their prowess over the Win32 development tool.

If keen, your main port of call should be the Embarcadero Certification Center. Here you'll find information about the two levels of certification on offer.

Firstly there is the basic Delphi Developer Certification that tests general knowledge of Delphi syntax, programming techniques, the IDE and database development. Those who have a registered copy of Delphi XE or RAD Studio XE can take this certification test for free (if they request a test code before the end of July 2011 and use it within 90 days). For others it will cost $US49. It would be advisable to check out the Delphi Developer Certification Exam Study Guide before taking the test, which can be taken online.

There is also the Delphi Master Developer Certification, which tests more advanced knowledge of Delphi concepts, architecture choices, syntax, techniques, IDE, projects and groups, component use and development, client/server, Internet and multitier development. This test needs to be taken at a Certification Center and will cost $US149. There is also a Delphi Certified Master Developer Exam Study Guide to check out before taking the test.

Monday 6 June 2011

More Android command-line fun

Following on from yesterday’s post about building Android apps at the command-line, this post looks at more things you can do with the command-line tools

You might normally start up an Android emulator (or Android Virtual Device) by running android.bat. This invokes the Android SDK and AVD manager, but unlike when you run SDK Manager.exe, it does not immediately connect to the network and update the list of available SDK packages. Instead it starts on the Virtual devices page and lets you create, edit or start an emulator.

Android SDK and AVD Manager

If you can remember the name of the emulator you want to start, say Android_2.2, then you can invoke it directly with:

emulator -avd Android_2.2

or, even simpler:

emulator @Android_2.2

Most interaction with the emulator or the device is done with the Android Debug Bridge (adb.exe). As mentioned in the last post, running adb devices will enumerate all connected devices and emulator instances and list out their serial numbers and connected state. Any emulators have the word emulator in their serial number to make it easy to spot them.

On occasion I've had problems with adb failing to notice an emulator that has been started up after initially working with a real Android device. This is usually overcome by telling adb to remove itself from memory and reload. adb acts like a daemon and normally stays running in memory between invocations, so to kill it you can use:

adb kill-server

The next time you run an adb command the daemon will be re-started. Note that killing the daemon also gets over problems where the adb in-memory process retains a handle on an Android package that's been installed. I've bumped into the issue several times, where trying to move or delete an Android project directory has been thwarted because something has a handle open on a file in the project directory tree. This often seems to be adb and killing it frees the handle.

Sunday 5 June 2011

Android from the command line

Whilst working with Mono for Android I was pretty much confined to the IDE with regard to building apps and deploying them to the emulator or to a real Android device. That was quite important as Mono for Android had various non-standard additional steps to ensure all the pieces were in place, what with there being a Mono layer, and dependencies (at least with debug builds) on the Mono shared runtime and a platform-specific additional runtime.

Now that I’m working with Project Cooper, building native Android apps, I have the same luxury of choice as a Java developer. I can do everything in the development environment or drop to a command prompt (if in Windows, or a terminal on Linux or on a Mac, though to simplify things I’ll be assuming Windows) and do any amount of stuff from there.

I figured it may be an idea to run through the steps involved in turning a .jar file into an Android app, getting on a device or emulator, and starting it. In other words show a variety of Android-related commands that I’ve been using recently.

Saturday 4 June 2011

Booting a VM from USB

Recently I started up my Linux VM for the first time in some months. It has Ubuntu installed on it. It had version 9.10 on it, known as Karmic Koala. I found out pretty quickly that this version is rather dated, and that support for it ended in April 2011. I decided to upgrade but was unsure whether to go for 10.04 LTS (Lucid Lynx), 10.10 (Maverick Meerkat) or 11.04 (Natty Narwhal) but didn’t want to fully install each one just to see what it was like.

Popping along to the Ubuntu download page I found that they offered the 10.04 Long Term Support (LTS) version or the current 11.04 version for download as a CD .ISO image and was reminded of the fact that the CD has the option of running as a ‘Live CD’, meaning you don;t have to install it – you can boot off the CD and run it directly from there. That’s great – I can pull the .ISO files down, connect my VM’s CD drive to the .ISO imge (as VMWare Workstation allows you to do, and I’m sure the other VM software, Virtual PC and Virtual Box do also).

Then I noticed the suggestion that you can burn the ISO to a bootable USB device and boot off that. This sounded interesting. When I decide on a suitable Ubuntu version, I can burn it to a spare USB memory stick and free the PC of the .ISO file, potentially allowing me to boot pretty much any PC into Ubuntu if the need or desire arises.

Well, I figured I’d better test this by booting my VM off the USB device. The first problem was how to make a bootable USB device from the .ISO, but this one is easily solved. The Ubuntu download page has a link to the Universal USB Installer from This makes the whole process trivial and even allows any spare space on the USB stick to be used as persistent storage for the installed Linux OS.

Universal USB Installer

Having got a bootable USB device with Ubuntu on it I need to prove that one of my virtual machines can successfully boot from it. And this is where things got sticky. It seems the VMWare BIOS does not support booting from USB devices, which seemed to rain on my parade, somewhat. Until I did a little searching and came across a free boot manager called, simply, Plop. You can read up all about Plop on their Boot Manager info page.

In short though, if you download the current Plop Boot Manager .zip archive and unzip it you’ll find 2 key files in it: plpbt.img (currently 1,474,560 bytes) and plpbt.iso (currently 327,680 bytes). The .img file is a bootable floppy disk image, hence being 1,440 kB (floppies used to be described as having a capacity of 720 kB or double that, which was referred to as 1.44 MB). The tiny .iso is a bootable CD image. If you connect one of these to the virtual floppy drive (if present, though there should be an option to add it if not) or the virtual CD drive in a VM (and ensure the BIOS is set to boot off the legacy floppy device or the CD-ROM drive before the hard drive) then Plop will be invoked.

Plop’s job is to present you with all the available bootable devices to boot from, including USB, and in that it works just great and allows the VM to boot successfully from a USB device.

Plop Boot Manager

Of course what you don’t see in the screenshot above is that all those dots are actually a very smooth star field you’re heading through.

Ok, so there we go – I now have a bootable USB device and I can boot any reasonably modern computer from it and can also boot a VM from it. One final thing I thought would be useful was to set up a dedicated dummy VM that could be used to boot from CD or USB devices, if desired, to avoid occupying one o the regular ‘real’ VMs. I wanted this dummy VM to take up as little space as possible and so, preferably, not have to chew up physical disk space by allocating a virtual hard drive, which after all won’t be used.

I went through the steps of creating a new VMWare VM, decided to tell VMWare that it would be a Linux guest OS that would be installed, but that it would be installed later and found there was no way of specifying no hard disk in the VM. I opted to use an existing virtual disk from another VM, but wasn’t too happy about making this dummy VM dependant on another one that my get moved to another physical drive at some point. So when the VM setup was complete I took a look in the new VM’s .vmx file, which contains all its main settings.

Near the top I saw these values:

scsi0:0.present = "TRUE"
scsi0:0.fileName = <path_to_some_VMs_vmdk_virtual_disk_file>

The last piece of the puzzle was to simply set the scsi0:0.present value to "FALSE". Now I have a trivial VM with no hard disk whose sole purpose is to boot an OS from either a CD, via a connected .ISO file, or from a USB device, which can be done by connecting the Plop floppy image or CD image to the VM.