Porting Galcon using the Android NDK
I’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
August 3rd, 2010 at 3:37 pm
Yes! Android needs more quality games!
August 3rd, 2010 at 4:17 pm
Congrats on a job well done.
August 3rd, 2010 at 5:51 pm
Does this allow Android Players to play iPhone players? Kinda like iPad can play against computer.
August 3rd, 2010 at 6:02 pm
[…] 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 […]
August 3rd, 2010 at 7:35 pm
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.
August 3rd, 2010 at 7:39 pm
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.
August 3rd, 2010 at 9:52 pm
From a non-developer point of view, porting it to another platform in a week is impressive. Is this timeframe normal?
August 4th, 2010 at 3:01 am
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 π
August 4th, 2010 at 4:02 am
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. π
August 4th, 2010 at 5:03 am
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 π
August 4th, 2010 at 9:55 am
@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).
August 4th, 2010 at 3:43 pm
I bought this game for the PC and iPhone so far, and now I can’t wait to buy it for my Nexus One!
August 5th, 2010 at 2:12 am
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.
August 5th, 2010 at 9:52 pm
@PhilHassey Regardless, it seems like a triumph to port it to a whole new platform in a couple weeks.
August 10th, 2010 at 9:14 am
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
August 17th, 2010 at 7:40 am
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!
August 17th, 2010 at 7:47 am
Correction, I meant to say, “But this does NOT deter me from investing development time on the Android platform.”
August 17th, 2010 at 9:19 am
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