Creating a 3D viewer for our Apollonian service using Android – Part 1

In the last post, we looked at an approach for bringing data from our Apollonian web-service into a Unity3D scene. Our next "off piste" look at consuming data from this web-service is on the Android platform.Android logo

This is my first serious attempt at mobile development (ignoring some fooling around I did with Embedded Visual C++ for Windows Mobile, way back when) although I have spent some time looking at WinRT (which basically means I've now built a Windows Phone 8 app, I suspect :-).

So why did I choose Android, rather than iOS? No real reason: I have both iOS and Android devices, and just picked one to start with. Although if I'm honest, deep-down I suspected the learning curve for a C# programmer would be shallower to learn Java that it would be with Objective-C. That was probably a reasonable assumption – I've found working with Eclipse and the Android stack pretty quick to adjust to, at least – but that doesn't mean it's a good reason to choose a platform, of course: I'll certainly take the plunge and try to do something comparable with iOS, when I get the chance.

I'm not actually going to post code, today, as I'm still making some "final" tweaks to get the UI right. But I will talk about the development process I've been following, so far.

Let's start with some technology choices (beyond the choice of the Android platform, of course)…

To develop a 3D app for Android, it seems the logical choice is to use OpenGL ES, as the Android SDK supports it directly. Whether you go for OpenGL ES 1.0 or 2.0 seems to depend on the age of hardware you want to support: as I'm primarily targeting the Kindle Fire – the only Android device I currently possess – I was able to go with 2.0.

I was loathe to code against OpenGL directly – as it's a C-based, procedural API – so I went a-hunting for an object-oriented layer. My first discovery was min3D, but that was based on OpenGL ES 1.0. But from there I discovered a more recent framework written by Dennis Ippel – who had previously worked on min3D – called Rajawali. Rajawali is an open source, object-oriented framework available on GitHub that saves you from having to deal with the mess-C-ness (ouch) of OpenGL ES 2.0.

On to my first Android/Rajawali app…

I followed the steps outlined in this "getting started" resource, to at least get the development environment set up. I went with "API level 10", which apparently equates to Android 2.3.3 (the Kindle Fire runs a customised version of Android 2.3.4, it seems, so this was as high as I felt I could safely go and still have it work). The Android SDK manager was helpful for getting hold of the version I wanted (although I ended up bringing down a few older versions, before settling on 2.3.3).

Android SDK Manager

Rather than going through the typical "Hello World" tutorial, I went directly across to follow the basic Rajawali tutorial. The fact it dealt with creating a sphere seemed like a bonus. 🙂

I was impressed with how quickly I got the basic app working, although it took me a while to work out how best to debug it. The standard device emulator that comes with the Android SDK does not support the use of OpenGL ES 2.0, which means you have to debug via a physical device. I started by manually building my application into an .apk file and transferring it across via USB and opening/installing it via ES File Explorer (this appears to be a fairly standard approach for side-loading apps onto the Kindle Fire). This process became old pretty quickly, I have to admit, and I didn't have much information passed back on things that didn't work.

Luckily, I came across these instructions for connecting the Kindle Fire to ADB (ADB is the Android Debug Bridge, by the way, and manages the connections with your development system and both physical and virtual Android devices), which allowed me to debug directly on the Kindle Fire from Eclipse via USB. This allowed me to step through code on the device and get information on any unhandled exceptions that occurred, greatly streamlining the development process.

OK, that's about it for today's post. To give you a taste of where we're heading… in the next post post we're going to build an application that allows us to query and view the various levels of our Apollonian sphere packing:

Level 1Level 2Level 3Level 4Level 5

The entire app is going to comprise of around 1,000 lines of code – which I think is pretty good, considering. We'll implement some rudimentary UI for changing levels, progress bars for both download and processing, and even touch gestures such as pinch-zoom, drag-rotation and swipe-spinning.

6 responses to “Creating a 3D viewer for our Apollonian service using Android – Part 1”

  1. "I have both iOS and Android devices, and just picked one to start with. Although if I’m honest, deep-down I suspected the learning curve for a C# programmer would be shallower to learn Java that it would be with Objective-C."

    I use C# for both Android and iOS

    xamarin.com

  2. Kean Walmsley Avatar
    Kean Walmsley

    Interesting - thanks, Tony.

    I suppose I should have clarified that there are frameworks that allow you to target different platforms from languages such as C# (just as we saw last time with Unity3D), although I admit I don't have any personal experience of them (other than with Unity, and that was targeting web/desktop rather than mobile).

    I've also heard good things about Appcelerator, but then that's JavaScript based, so doesn't necessarily help us C#-heads.

    One thing I should add for other readers... it's clearly a tricky job choosing a particular cross-platform framework (especially in the long-run). And I'm certainly not in a position to advocate any particular system: my choice in this series was to focus on free tools - and to get some exposure to the native development experience, as that's fun to do, too. 🙂

    Kean

  3. Horatio McDowney Avatar
    Horatio McDowney

    Any hope that one might be able to employ PhoneGap (phonegap.com/). Seems like (in the long run) it should cut down on the work that needs to be done on both Apple and Google environs. (BTW, I'm just getting caught up to these Android and iOS posts. So if you have commented on this already, please forgive me.)

    All the best,

    -H

  4. Kean Walmsley Avatar
    Kean Walmsley

    Yes - I'd definitely expect some kind of cross-platform technology to be the way to go, in the near- to medium-term. There are a slew of them out there, and it seems like I find out about a new one each day: Xamarin, Appcelerator, PhoneGap, MoSync, Unity3D... I imagine they all have relative strengths/weaknesses. The trick is betting on one that has legs and can meet your needs in the long run.

    Longer-term I still have high hopes that HTML5 will provide adequate enough performance to mean we can skip "compile to native" toolkits/middleware.

    But then the whole native app emergence took me by surprise, so who knows how long that will continue (and, if you listen to some, the benefits in terms of performance/power consumption is driving developers closer to the metal on mobile devices, increasing usage of unmanaged code (C++) for many apps... go figure).

    Kean

  5. I showed android-sdk and related gadgets from the Android planner site. I clung to their heading to make a HelloWorld application, at any rate I am getting a few wreckage heaps up which I don't get it.career work network

  6. You could make boatloads of money if you can make one application in your additional time. Simply thing you must have is vitality for coding.career work network

Leave a Reply

Your email address will not be published. Required fields are marked *