Android x86 Emulator and NDK

The recently released Android SDK Tools r12 added x86 and ARMv7 support to the emulator and AVD manager. However, the system images included with the SDK are still ARMv5 only, resulting in the AVD manager running in legacy mode with the ABI drop-down box disabled. This post will show you how to build new images from scratch.

The system images for each platform are located in android-sdk/platforms/android-#/images/, and you’ll need to create sub-directories for each architecture:

  • images/armeabi for ARMv5
  • images/armeabi-v7a for ARMv7
  • images/x86 for x86

Until pre-built x86 images are included with the SDK, they will need to be compiled from source. The following steps assumes that the build environment has been configured correctly and that repo is in your path. Get the AOSP source code and and build the full\_x86-eng product

 $ mkdir mydroid; cd mydroid
 $ repo init -u git://android.git.kernel.org/platform/manifest.git
 $ repo sync
 $ . build/envsetup.sh
 $ lunch # Select 'full_x86-eng'
 $ make

As long as you have the environment setup by sourcing build/envsetup.sh you can then launch the newly built x86 emulator with

 $ emulator

or copy the system images from out/target/product/generic_x86/ to the correct SDK directory and launch via the AVD manager. As explained in a post by Jean-Baptiste Queru, the x86 emulator is architecturally similar to the ARM version, with no virtualization. Additionally, the x86 graphics pipeline isn’t as optimized as the ARM one yet. This means that the x86 emulator is actually going to perform worse than the ARM emulator (for now). If you want to run an application containing native code on the x86 emulator, you’ll need to build it using the latest NDK (revision 6) which has the required toolchain and libraries. To compile an application for x86 (and/or ARMv7) using the NDK, add the desired ABIs to your Application.mk:

     APP_ABI := armeabi armeabi-v7a x86

and build as usual with ndk-build.

Tip: Running android-x86 in VirtualBox is a good alternative when you need better performance and can make do without the extra features of the emulator.