Guide: How To Implement native Intel x86 Support for Android Apps to boost performance

Guide: How To Implement native Intel x86 Support for Android Apps to boost performance
HIGHLIGHTS

Here's a guide on how to add native Intel x86 support for your Android apps. Adding native support helps to drastically improve the performance of Android apps, when running on Intel x86 based devices.

My name is Antonio De Falco, and I am the creator of the game Planet Conqueror. Having graduated from University as a Game-Designer, I found myself inclined to develop games that are easy to get into but that still deliver long-lasting fun while playing it.  In this post, I shall guide you on how to add native Intel x86 support for your Android App, for this guide i have used my own game app- 'Planet Conqueror' as an example to show you the procedure for adding native x86 support for an app that is build using libGDx.

Planet Conqueror was built using libGDX version 0.9.8 (stable release) which did not have the needed support for Intel based devices. Luckily the newer version of the framework did. So first of all, we need to download the new version of libGDX (ver. 0.9.9 or higher). LibGDX offers stable releases that are tested and contain few to no bugs. Another option is to download the nightly builds that have more features but probably more bugs, too. If you want to risk it, you can download the nightly build otherwise go for the stable release. You’ll find both downloads here: Download setup App

Once the download is complete, extract the zip file to a location of your choice. We are going to overwrite some files and delete some others.

  • First copy “gdx.jar” from the extracted folder into the “libs” folder of core project.

  • Than we need to replace the “libgdx.so” files and the Android Backend in the Android project folder. Copy the “armeabi”, “armeabi-v7a” and “x86” folders and “gdx-backend-android.jar” from the extracted folder into “…\YourApp-android\libs\” folder.

  • While you are in the libs folder of your Android project, go into “armeabi” and “armeabi-v7a” and delete the “libandroidgl20.so” files.

  • Lastly copy and paste “gdx-backend-lwjgl.jar”, “gdx-backend-lwjgl-natives.jar” and “gdx-natives.jar” form your extracted folder into “…\YourApp-desktop\libs\” folder.

Having support for x86, ARM and ARMv7 incorporated in one “fat build” the Android OS will sort out what files to use all by itself. If you are using libGDX extensions for your app, you also need to copy the updated extension files to your project. In the case of Planet Conqueror it was the Freetype extension which allows loading font files instead of creating bitmap fonts.

  • Just like before, copy “armeabi”, “armeabi-v7a” and “x86” folders from “libgdx \extensions\gdx-freetype\” to the “libs” folder of your Android project.

  • Do the same for “gdx-freetype.jar” and “gdx-freetype-natives.jar” in the core projects “libs” folder.

Now that the first step is complete, you can start your IDE. You may notice some code errors showing up. This is due to changes that were made to libGDX in between the two versions. Check the documentation and change log to solve the errors that are specific to your app.

After that, you are ready to compile a build with x86 support and start testing for functionality. To do that you need to set up the emulator with the x86 system image from Intel. You will find a detailed explanation on how to work with the x86 system image here: Speeding Up the Android* Emulator on Intel® Architecture

I do recommend reading the article above because it contains a lot of extra information which I will skim or skip in this article. Since I am working with Windows, I will skip the procedure for other operating systems. So if you do not use Windows, please refer to the link above. To start your newly build APK on a x86 emulator you need a few perquisites. The Android SDK which you probably have already installed and a computer which runs on an Intel processor with support for “…Intel VT-x, EM64T and Execute Disable(XD) Bit functionality…”. This all sounds more complicated than it actually is. I’ve managed to run an emulator with an x86 system image on an Intel Core 2 Duo E6600 first released around mid-2006. So, if you have a newer CPU, chances are that you got all of these perquisites. These functionalities must be enabled from the BIOS, but do not worry about it yet.

Let’s start by downloading the Intel HAXM (Hardware Accelerated Execution Manager) from here:Intel Hardware Accelerated Execution Manager

Go to the location of the downloaded file and extract and/or execute “intelhaxm.exe” to start the install wizard. During installation progress you may get an error message, telling you that Intel VT-x is not enabled in the BIOS. If so, you need to abort the setup restart your computer and enter the BIOS at startup (Please refer to the Mainboard owner’s manual on how to enter the BIOS) there you need to set “Virtualization Technology” to “Enabled”. Save and exit the BIOS and restart the installation of Intel HAXM following the same steps as before.

Now that we have the accelerator installed we need to create an AVD (Android Virtual Device) with an Intel system image. Choose an Android version you want to use and download the image here: Android tools (find different versions on the bottom of the website). Or use the Android SDK Manager for convenience. Once you have your system image(s) start the AVD Manager from the Android SDK Tools “…\android-sdk\AVD Manager.exe” and create a new AVD. Set up the new AVD as you need it to be. The only thing you need to do differently is to set “CPU/ABI” to “Intel Atom (x86)” and you have an emulator that runs with x86 architecture.

All you have left to do is test your app according to your testing-checklist. Of course, you do not have to test everything if you already tested your app thoroughly. Confine your testing-checklist to things that are relevant for the CPU. Do a comparison of the two builds on the emulator and/or a device to see how much of a difference it makes with your app.

The process of implementing x86 support into Planet Conqueror was fairly easy thanks to the libGDX framework. It was just a matter of updating the development framework, copying some files into the project, and the build for x86 devices was ready. From here it was a matter of testing it out to see if there were any hiccups during runtime. Getting the x86 emulator running was the first step, and it was completed quickly because of the drivers available for Intel powered desktop machines. Getting a hold of an actual device with x86-architecture was a bit harder but also manageable. In the end, no hiccups were found, and a new version of Planet Conqueror was ready to be uploaded to the Store for the x86-community to download.

Author Bio

Based in Krefeld (Germany), Antonio De Falco is, among other things, an independent game developer for Android devices. He graduated from University, with a bachelor’s degree in game-design. Since his studies, he has worked in Cologne and Paris, where he gained further experience in the surroundings of experienced software development companies. 

Other Related Articles and Resources

For more such Android resources and tools from Intel, please visit the Intel® Developer Zone

 

Promotion
Digit.in
Logo
Digit.in
Logo