The 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:
- Download and install Oracle VirtualBox
- Download an Android-x86 system image from the project’s website. The recommended version for VirtualBox is “eeepc”.
- Create a new Virtual Machine in VirtualBox with the following parameters:
- OS: Linux Kernel 2.6
- Memory: 512MB
- Hard Disk: 2 GB, Dynamic
- Edit the device, and change the network card to PCnet-FAST III
- Change the network mode to “Bridged”
- 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″
- Start the Virtual Machine, and load the Android-x86 ISO
- Install Android-x86 on the VM, and be sure to create an SD-Card of at least 200 MB
- Unmount the Android-x86 image, start the VM, and when GRUB loads:
- Press the “a” key
- Append “vga=ask” to the Kernel parameters
- Write down the HEX key of resolution “480×800”, it may be “360”
- Convert HEX to Decimal, in this case “360” would be “864”
- Reboot, and start GRUB in “Debug” mode
- Enter the following commands:
- mount -o remount, rw /mnt
- cd /mnt/grub
- vi menu.lst
- Add “vga=864” to all kernel lines
- Save, exit, and reboot
- Start the VM and turn off “Enhanced Mouse Integration”
- When the VM starts, press “Alt+F1”, and type “netcfg” to get the IP
- Press “Alt+F7” to get back to the Android OS
- Armed with the IP address, connect the Android developer environment to the device:
- 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]
- On the host PC, open the command prompt, navigate to the Android SDK directory, and run:
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:
- To press “back”, hit the escape key
- Press the Android power button by going to the menu and clicking “ACPI Shutdown”
- 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+
Great information. I will check out the rest of your blog.