A Faster Android App Emulator using Android-x86

Android DevelopmentThe key to successful rapid application development is a fast deployment and testing environment. Quick builds and deployments enable better testing of new functionality, since the developer retains the changes fresh in his mind and can make fixes iteratively instead of in large batches. Altogether, this results in more polished, full-featured apps, and faster app time-to-market.

While the Android build and testing environment provided by Google has many excellent features, there are only two built-in ways to deploy and test apps. The first is to deploy directly to a phone, and the second is to deploy to an emulator – a software version of the phone running on the PC.

Unfortunately, Google’s Android emulator runs extremely slow on many PCs. The emulator is actually a Virtual Machine that runs ARM instructions, so each Java app first needs to run in Android’s Java VM, then get translated to ARM, and finally emulated from ARM to x86. This causes significant lag in phone operation. While native extensions do exist for certain processors, such as Intel processors supporting virtualization, many other processors and development environments are not supported.

Fortunately, a good alternative emulation solution exists. Instead of using the built-in Google emulator, it is possible to build a custom Android emulator using the Android-x86 project. This port of Android to the x86 platform allows the emulator to be installed within a standard VirtualBox instance, and results in much faster speed and interactivity while reducing the memory footprint.

Setting up the Android-x86 emulator can take a little work, however it will reap significant dividends in reduced app development time. Steps to set up the Android-x86 emulator are as follows:

  1. Download and install Oracle VirtualBox
  2. Download an Android-x86 system image from the project’s website. The recommended version for VirtualBox is “eeepc”.
  3. Create a new Virtual Machine in VirtualBox with the following parameters:
    1. OS: Linux Kernel 2.6
    2. Memory: 512MB
    3. Hard Disk: 2 GB, Dynamic
    4. Edit the device, and change the network card to PCnet-FAST III
    5. Change the network mode to “Bridged”
    6. Save the machine, close VirtualBox, then navigate to the VirtualBox directory and run the following command:
      VBoxManage.exe setextradata “[NAME_OF_ANDROID_VM]” “CustomVideoMode1″ “480x800x16″
  4. Start the Virtual Machine, and load the Android-x86 ISO
  5. Install Android-x86 on the VM, and be sure to create an SD-Card of at least 200 MB
  6. Unmount the Android-x86 image, start the VM, and when GRUB loads:
    1. Press the “a” key
    2. Append “vga=ask” to the Kernel parameters
    3. Write down the HEX key of resolution “480×800”, it may be “360”
    4. Convert HEX to Decimal, in this case “360” would be “864”
    5. Reboot, and start GRUB in “Debug” mode
    6. Enter the following commands:
      1. mount -o remount, rw /mnt
      2. cd /mnt/grub
      3. vi menu.lst
    7. Add “vga=864” to all kernel lines
    8. Save, exit, and reboot
  7. Start the VM and turn off “Enhanced Mouse Integration”
  8. When the VM starts, press “Alt+F1”, and type “netcfg” to get the IP
  9. Press “Alt+F7” to get back to the Android OS
  10. Armed with the IP address, connect the Android developer environment to the device:
    1. On the host PC, open the command prompt, navigate to the Android SDK directory, and run:
      platform-tools\adb.exe connect [IP_OF_ANDROID_VM]

After these steps, the PC should be connected to the Android phone, and running at the correct resolution. A few shortcut keys to interfacing with the Android device:

  1. To press “back”, hit the escape key
  2. Press the Android power button by going to the menu and clicking “ACPI Shutdown”
  3. Press the settings key by hitting the “Properties” or “Context” key on a Windows keyboard

This should result in a high-performance Android device, ideal for quick, iterative app testing. Due to the bridged network interface, this would even enable the emulator to run on one PC, and the development environment on another. Although some frameworks that require ARM instructions, such as Mono, will not work in this scenario, the Android-x86 emulator will support the majority of Android apps, and help to both improve code quality and reduce coding time in the app development process.

Written by Andrew Palczewski

About the Author
Andrew Palczewski is CEO of apHarmony, a Chicago software development company. He holds a Master's degree in Computer Engineering from the University of Illinois at Urbana-Champaign and has over ten years' experience in managing development of software projects.
Google+

RSS Twitter LinkedIn Facebook Email

One thought on “A Faster Android App Emulator using Android-x86”

Leave a Reply to Betty Ann Cancel reply

Your email address will not be published. Required fields are marked *