Things I Wish I Knew Before I Built My First Android-x86 from Google Source Supported by Intel

Published:02/24/2012   Last Updated:02/24/2012

Last week, I was in cycle of several Android developers and partners who have needs to compile and build their own Android for Intel x86 platform from Google source repository, and read through a lot of success/unsuccessful stories.  I decided to try my own build. That  was a wonderful journey and learning experience. Even though I have pretty of resource and help available around, I still made some wrong turns at different cross-roads, and got to say that back on track wasn't easy. To save your time doing the same, read on:

Start with  64 bits Ubuntu for your development platform build, and forget any 32 bits OS

I had a 32 bits Ubuntu in my lab, and I  love Ubuntu and trust that my apt-get should get everything I need. This is my first wrong turn and here are the results:

  • I always had problems with the build failures due to erroneously using some 64-bit or 32-bit libs/headers ( several times I thought I almost fix them).

  • Google Source Repository allow a single repository download for a single gmail account and a specific IP address only for an unknown time period. No 2nd try. It is very reasonable as each download transfer 2-4G  of data. I made my mistake on 32bits, and after I built my 64-bits and tried again, No luck!

  • Latter, I found notes from Google: " By default, access to the Android source code is anonymous. To protect the servers against excessive usage, each IP address is associated with a quota"

You can download  and install Ubuntu 10.04 (64-bit)  as below

  • Download Ubuntu [1], 64-bit edition

  • Burn the ISO to CD, or follow the document in the page to create a bootable USB stick

  • Boot from CD or USB

  • Install

Make sure your check your OS and make sure it is 64-bit. You can "uname -a", and check if you see x86_64.

Set up your Proxy Server (Skip this step if your system connects directly to Internet)

Again, do your repo sync through a proxy is very tricky, and make sure you do this step right

For GNOME (Ubuntu 10.04/10.10/11.04):

Go to System->Settings->Network Proxy. Click on the 'Proxy Configuration' tab and enter in the proxy for your site. After that, click on the 'Ignored Hosts' tab and make sure all the sites you don't want proxy (localhost,, .local,, your.corporate.ip are listed there. Once done, click 'Apply System-Wide...' and then close the dialog. You are not done yet.


Edit your bashrc file, located at ~/.bashrc, and add these lines at the end:
export http_proxy=http://your.corporate.proxy:port#
export https_proxy=https://your.corporate.proxy:port#
export no_proxy=localhost,,,

Git Proxy Settings

You will need a program called connect [2] for Git to utilize proxy (although if you know what you are doing, you can use whatever you like to connect via SOCKS). You can download the source at and compile. Or if you are using Ubuntu, you can install the package connect-proxy by:

$ sudo apt-get install connect-proxy

After you have the connect program, you will need a script for Git to use. It will choose whether to connect through the proxy depending on the URL of the repository. Create and edit a new file named socks-gw. In it, put the following code:

echo $1 | grep "\.yourcorporatename\.com$" > /dev/null 2>&1
if [ $? -eq 0 ]; then
connect $@
connect -S $@

You should put this somewhere on your path (e.g. ~/bin/). Remember to make the script executable by doing:

$ chmod +x PATH_WHERE_YOU_PLACED_UTILS/socks-gw

Then inside ~/.bashrc, add:

Check Environment Settings

You can restart your terminal and see if the necessary environment variables are exported. After restarting the terminal, execute the following commands to check:

$ echo $http_proxy
$ echo $https_proxy
$ echo $no_proxy

Installing the correct version of Java SDK

Android relies on a JDK that is older than the one provided in newer Linux distributions. So do not always choose the latest Java SDK. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used. Java 6 should be used for Gingerbread and newer
$ sudo add-apt-repository "deb lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

Or get the JDK from oracle. Unpack it into your $HOME/bin/ and edit your .profile or .bashrc to set up the search path to find the javac in your $HOME/bin/jdk1.6.x_xx/bin before anything that may be on your distro install.

Add something like following to the end of ~/.bashrc: be sure to match the path's with whatever java you ended up with, or simply updating your PATH; (i.e. PATH=$HOME/bin/jdk1.6.0_xx/bin:$PATH)

$ export JAVA_1_6=$HOME/bin/jdk1.6.0_xx
# Adjust the next line if necessary, $JAVA_1_6 for Gingerbread
$ export JAVA_HOME=$JAVA_1_6
$ export JAVA_FONTS=/usr/share/fonts/truetype
$ export ANT_HOME=/usr/share/ant
$ export CLASSPATH=.

Note: replace xx with your actual version #

For Ubuntu (Apt-based)

Enable the Canonical Partner repository
Open Synaptic (normally, it's under System -> Administration)
Inside Synaptic, Settings->Repositories->Other Software
Make sure Canonical Partners entry is checked
Close Synaptic

Open a terminal. Do the following (exclude the $ sign):

$ sudo apt-get update
$ sudo apt-get install zip build-essential curl git-core \
python gcc patch flex bison gperf \
g++ squashfs-tools sun-java6-jdk \
ia32-libs g++-multilib zlib1g-dev \
lib32z1-dev lib32ncurses5-dev \
gcc-multilib libwxgtk2.8-dev \
tofrodos texinfo mtools

To make sure you will not miss any packages. Run the Google recommended below again:

$ sudo apt-get install gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32  python-markdown \
libxml2-utils xsltproc

No need to worry about the duplications, just to make sure you will not miss any packages. Then:

$ sudo ln -s /usr/bin/fromdos /usr/local/bin/dos2unix

On Ubuntu 10.10:

$ sudo ln -s /usr/lib32/mesa/ /usr/lib32/mesa/

On Ubuntu 11.10:
$ sudo apt-get install libx11-dev:i386

Installing Repo  and Downloading the Source Tree

Repo is a tool that makes it easier to work with Git in the context of Android. To install, initialize, and configure Repo, follow these steps:
Make sure you have a bin/ directory in your home directory, and that it is included in your path:

$ mkdir ~/bin
$ PATH=~/bin:$PATH

Download the Repo script and ensure it is executable:

$ curl > ~/bin/repo
$ chmod a+x ~/bin/repo

Initializing a Repo client After installing Repo, set up your client to access the android source repository:

Create an empty directory to hold your working files:

$ mkdir gingerbread
$ cd gingerbread

Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.

$ repo init -u

The branch label “gingerbread”  has the required build files and modules needed to build the x86 SDK Emulator images. The Ice Cream Sandwich branch will be available shortly. To check out gingerbread branch only other than "master", specify it with -b:

$ repo init -u -b gingerbread

When prompted, configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions, and also in the Android info page you build.

A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.

Getting the files

To pull down files to your working directory from the repositories as  specified in the default manifest, run

$ repo sync

The Android source files will be located in your working directory under their project names. Dependent on how fast your system is and your network, the initial sync operation will take about an hour or more to complete.

Building the Android System

Initialize the environment with the script. Note that replacing "source" with a single dot saves a few characters, and the short form is more commonly used in documentation.

$ source build/

including device/htc/passion/
including device/samsung/crespo4g/
including device/samsung/crespo/

Choose a Target

Choose which target to build with lunch. The exact configuration can be passed as an argument, e.g.

$ lunch
Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. simulator
4. full_passion-userdebug
5. full_crespo4g-userdebug
6. full_crespo-userdebug
Which would you like? [full-eng]: 2.

Then, you will see:

Building the Code

$ make -jN

While N is the total core of CPU of your system. The more core you have, the faster it build.
If your build is successful, you will have the following files in



Next, you are ready to:

  • Flash your Android build to your device

  • Build an Android installer iso

  • Create an Android AVD emulator

  • Build a Virtualbox.

Android Ice Cream Sandwich is coming very soon. Same process applied to  ICS. However, any app or system developer will have to keep in mind that over 95% of Android smartphone are using Android Gingerbread or earlier version. To make your app backward capable, you need to make sure your App running well on Gingerbread.

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804