I’m Jean-Claude Cottier, a video game industry veteran. I’ve been working in this field for the last 18 years and in 2008, I’ve setup my own solo game studio: Ovogame. My games are available on few platforms including Android: http://bit.ly/1i8aA1D. I have optimized all my games for Intel architectures and it was dead simple. I’ll give you a quick overview of the problem and how to solve it.
When you develop natively for Android, the NDK is compiling your C++ code into a library that can be integrated in the Java project (thanks to the JNI interface). In my engine, the Java code is kept to a bare bones minimum (mostly the communication with the system) and never change from one game to the other. It’s now possible to create an Android application using only C++ (no Java) but I don’t recommend it because sometimes you’ll want to use 3rd parties Java API (to display ads for example).
Nowadays, you can find different CPU powering Android devices (ARM, Intel x86…). This doesn’t matter for application developed in Java because it’s an interpreted language. But when you are developing in C++ like myself, you have to compile your code for specific architectures. The majority of Android devices are powered by ARM chip. Like many C++ developer, I was only targeting ARM architectures (armv5 and armv7). With the NDK, you can compile your code for different architectures: armv5 for old Android devices and armv7 for newer ones. It’s automatically managed by the system, your APK is containing both versions and when your user launch your application, the most appropriate code will be use. Devices powered with x86 architectures can’t run ARM code obviously (as they are different architectures). By consequence, these devices must interpret ARM code via a binary translator (houdini). Even if the x86 devices are doing an amazing job at interpreting ARM code, it’s a shame to not use their full capacity. If you compile your code for x86, your application will run faster on Intel based devices and it will consume less battery. Overall it will be a better experience for your users. It’s very easy to support as you simply need to include a new compilation target. From your Android project, you need to open the jni/Application.mk in an editor and update the APP_ABI variable (APP_ABI is defining the different targets). As I was only targeting armv5 and armv7 before, my variable was set like this:
APP_ABI := armeabi armeabi-v7a
To add support to the Intel architecture, you simply need to add x86 to the list.
APP_ABI := armeabi armeabi-v7a x86
Now, every time you’ll compile your application, you’ll get an extra library compatible with x86 architectures that will be added to your APK. When the application is install on an Intel based device, it’s this new compatible code that will be executed. All my games are now fully optimized for x86 devices. If like me, you are developing your applications in C++ with the NDK, you should also target for the x86 architectures. It’s so simple, it would be a shame not to take advantage of it.
Personally, I didn’t had any technical problems supporting this new target as my engine is using standard C++. In fact, I’ve recompile and updated all my games the same day.
You need to know that the APK will be a tiny bit bigger (to store the x86 code) which can be annoying if you are close from the 50MB limit on Google Play.
If you are using 3rd parties API only compiled for ARM, you won’t be able to use them anymore. This is why I try to use only external libraries with the source code provided because it’s more cross-platform friendly.
If you need to change something in your makefile depending on the current architecture being compiled, you can edit your Android.mk and add conditions:
ifeq ($(TARGET_ARCH_ABI), x86)
‘This code will be visible only when compiling the x86 target.’
If you want a more in depth article about porting you Android applications on x86, you could head to the Intel website: http://intel.ly/1jnDfAd
I really think that for the vast majority of developers using the NDK like myself (with their own engine or Cocos2D for example), adding the word x86 in the APP_ABI variable will be enough to support Intel based devices. You will agree that this is largely possible within a couple of minutes. You should do it.