Phil Hassey - game dev blog
Phil Hassey as Snidely Whiplash
"You can't buy awesomeness.
You're born that way."

Porting Galcon using the Android NDK

droidslimI’ve completed my port of Galcon (an iPhone game written primarily in C/C++) to the Android NDK – meaning I’ve kept the game written in C/C++ but I’ve replaced my ObjectiveC/iOS device interface with a Java/Android device interface layer.

Porting to the Android has been a thrilling experience, one that I will not soon forget. The epic journey took seven days of toil through the forests of software installation, Java integration, bug extermination, and quirk comprehension. I’ve journaled my quest in detail. This entry servers as a portal to that vast mountain of knowledge. I also include some final thoughts.

Android Day 1: SDK, Eclipse IDE, and device activation
This documents how I installed the Android SDK and NDK software, set up the IDE, and activated the devices. Through the rest of my process I did not use the Eclipse IDE, so that step can be skipped if you have the same goals as me.

Android Day 2: The NDK
Next I got the NDK installed and ran a few sample apps with it. I then found a port of STL for the Android NDK and dropped that into my codebase.

Android Day 3: Packaging, Assets, JNI, and OpenGL
With a bit of work I was able to get Java to talk to C and C to talk to Java. I also researched my options for packaging game assets such as graphics and audio, as well as got an OpenGL context setup and got Java loading my textures for me.

Android Day 4: Video cleanup, Input handling
I was able to get the visuals complete in the game, and added event handling for onTouchEvent’s. I also removed the title bar that shows at the top of the screen by default. The advice about onPause is a bit vague, but I explain a bit better in a later part.

Android Day 5: Keyboard, Multiplayer / Networking
After considerable searching I was able to find out how to get the software keyboard to display. I then worked on getting the multiplayer portion of the game working, which was rather challenging as the debugging tools did not seem to yield tracebacks, but they gave just enough that I was able to figure out what was wrong.

Android Day 6: Save games, Audio, other Details
During this day I focussed mostly on getting save / restore (or pause / resume) working better. I also got the audio features of the Android working on playing my music and sound effects. To wrap it up, I added the game’s icon.

Android Day 7: Leftovers
A lot of cleanup here – better pause / resume support, better device support, keyboard support, volume controls, copy protection, bugs, and signing. The game is running quite well now!

So that was my journey. It has been a challenging quest – I haven’t used Java in about 10 years, and doing Java-to-C integration is a fragile process! Learning to navigate through Java classes to get things done is not what I’m used to in the more simple worlds of C and python. But the port is almost ready, and I’m quite pleased with it.

-Phil

18 Responses to “Porting Galcon using the Android NDK”

  1. theineffablebob Says:

    Yes! Android needs more quality games!

  2. tomhiggins Says:

    Congrats on a job well done.

  3. digdog22 Says:

    Does this allow Android Players to play iPhone players? Kinda like iPad can play against computer.

  4. Galcon for AndroidOS | WSMF Web Thing Says:

    […] Sometime latter he decided to take a week and Β port the game to AndroidOS, he even documented his adventures in porting on his blog. Today it was announced the app will be out to the masses in a few days. I was fortunate enough to […]

  5. Guillermo Says:

    AWESOME!!! I love this game, been waiting for it to come out on android, been playing Flash version online since it was in beta testing.

  6. MattB Says:

    I’m psyched! Ever since getting my android I have been disapointed in the crappy Galcon remakes (archipelago, something else). I Will definitely buy this right away.

  7. Jomskylark Says:

    From a non-developer point of view, porting it to another platform in a week is impressive. Is this timeframe normal?

  8. Ziggy Says:

    GalaxIR on Android is a good game like Galcon. Its free and you can play online multiplayer and bluetooth multiplayer. And the gameplay is better πŸ™‚

  9. Frode Says:

    It’s a pity Google can’t seem to get their act together and open the Android Market up everywhere. Many countries, mine included, does not have access to anything but free apps in the Market. Based on the Android development entries, it seems there will be no way to purchase Galcon outside of the market, thus I won’t be able to get it. πŸ™

  10. nza Says:

    Fantastic news, I wish more iPhone devs would consider writing/porting for both platforms. I am attempting to learn Java and will read all the above advice with thanks πŸ™‚

  11. philhassey Says:

    @digdog22 – yes, Android users will be able to play against iPhone users!

    @Jomskylark – I don’t know. I’m not really done yet, since I’m doing beta testing and bug fixing before I release it. So there’s still a few days of work to be done, plus the post-release port work, so it’s really a pretty big job to do a port no matter how you look at it.

    @Frode – hmmm, I don’t know if there is anything I can do about that πŸ™ But I do hope the Android store gains greater availability.

    @nza – I didn’t port the whole game to Java, but I did have to write a bit of Java code to interact with the system (Audio, video, etc).

  12. Jon Sangster Says:

    I bought this game for the PC and iPhone so far, and now I can’t wait to buy it for my Nexus One!

  13. Frode Says:

    Regarding the Market issue, the only way around it currently is to include your own registration/activation system and distribute the apk directly. There are products that do this already (I own a few), but it obviously means more work for you.

    I really don’t get Google on this. There is zero technological issue in us paying for apps. Speculation is they want to allow paying via the phone bill, but that seems a weak excuse to lock out entire countries for years.

  14. Jomskylark Says:

    @PhilHassey Regardless, it seems like a triumph to port it to a whole new platform in a couple weeks.

  15. Zel Says:

    Nice to publish this experience feedback, it might be very usefull for other developpers.
    By the way, I’ve been waiting for Galcon for android for a long time!
    Exciting time! Thanks

  16. Pieter Says:

    Great work and great game! Thanks for the day-by-day technical write-up. It is nice to see such willingness to share real knowledge and experience.

    Sadly, I too cannot purchase via the Android market in my country and bought Galcon for the PC ages ago, so I am still playing the game on Windows.

    On the reverse side, I am also a programmer so not being able to sell Android software on the Market from where I live is a downer. But this does deter me from investing development time on the Android platform.

    Keep up the good work Phil!

  17. Pieter Says:

    Correction, I meant to say, “But this does NOT deter me from investing development time on the Android platform.”

  18. Pieter Greyling Says:

    BTW, I have posted a link to this article on the LinkedIn group
    “Android Invasion : Resistance Is Futile” at
    http://www.linkedin.com/groups?mostPopular=&gid=3277587