Android Virtual Machine Host Setup Recommendations

Showing results for 
Show  only  | Search instead for 
Did you mean: 

Android Virtual Machine Host Setup Recommendations

No ratings

Android Virtual Machine Host Setup Recommendations

Whenever possible is always better to avoid Virtual Machines when compiling Android as the building process might take several hours to even a day or two depending on the resources available to the Virtual Machine. Sometimes, however, a VM is the only option available and here are some useful considerations when using a VM as a host for Android builds. This document addresses some of the requirements for the Kit-Kat Freescale Android BSP although some may also apply to the general Android releases.

It’s recommended to use Ubuntu 12.04 64-bits as Host OS. As for HDD space, which is often a limited resource when using VM, Google states that at least 30GB of disk space in order to build the Android Tree. In practice, however, it’s recommended to allocate at least 100GB to the VM HDD if possible, as additional packages and larger images can quickly deplete disk space.

Installing Java (not VM specific)

It’s recommended (albeit not mandatory) to uninstall any version of Java other than the recommended for the specific Android release for which we will build. In the case of Kit-Kat this is Java 6. Another option is to just switch the java alternatives to the ones we want to use for Android.

There is a document with the exact instructions on how to install the required JKD on the following link.

How to install Sun's JDK in Ubuntu for Android build

Starting KitKat, however, it’s also necessary to install javap (Java Class File Dissasembler) so please also add these steps when following this document.

$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 1

$ sudo update-alternatives --config javac

Memory considerations when using a Virtual Machine

Using a Virtual Machine slows down the image building considerably. Besides that memory system is often also an issue. Having insufficient RAM especially on the linking part of the image build may cause a number of issues that are difficult to troubleshoot. In these cases it’s good to take a look at the resource monitor to see if indeed the RAM was depleted.

One way to make up for the limited RAM is using a bigger swap. Google recommends at least 16GB of RAM/swap so it’s not uncommon to create a 10GB swap when working in VM, to do this please use the following commands.

$ sudo fallocate -l 10g /mnt/10GB.swap

$ sudo chmod 600 /mnt/10GB.swap

$ sudo mkswap /mnt/10GB.swap

$ sudo swapon /mnt/10GB.swap

This will helps with the memory requirements but won’t speed up the build process. Building time with VM, as previously stated, will take several hours or even a couple of days depending on computing power.


Please submit any questions or issues related to this document as a discussion in the community.

Version history
Last update:
‎09-23-2014 01:27 PM
Updated by: