Developers

Get Source

by Chih-Wei Huang (cwhuang) 2009/07/10-2011/12/25

Introduction

This page has (hopefully) the latest information about how to build Android for x86 platforms like Eee PC. The built images runs well on a real hardware as well as virtual machines (qemu or virtual box).

Now it is very easy to compile Android for x86 platform from our git repositories. You need not to apply any patch. Just follow the below instructions.

The branches in Android-x86 tree

Since AOSP evolves very quickly, we have created different branches corresponding to different releases of AOSP:

If you hope to keep syncing your tree with Android-x86 repository, just do repo sync. No need to do repo init again. However, sometimes you may see conflicts during repo sync. See the below section for how to solve this situation.

Note: The Android-x86 repository is very big (about > 10GB). If you encounter problems of sync it, it's likely a network problem or our server is too busy. Repeatedly run 'repo sync' until it succeeds without any error. Do not bother us with any of the syncing problem.

Building the image

Once the repo sync is complete, you can build a cdrom iso image. You need Oracle java 1.6 (OpenJDK may not work) to build branches before (includes) kitkat-x86. . Since lollipop-x86, java 1.7 is required and OpenJDK is supported.

Note: Before froyo-x86 (included), you can build on either a 32-bit or 64-bit host. Since gingerbread-x86, a 64-bit build environment is recommended.

Choose a target

You need to choose a target for the x86 device you want to use/test. We provides several targets for different branches:

nougat-x86 / marshmallow-x86 / lollipop-x86

android_x86: for 32-bit x86 platform

android_x86_64: for 64-bit x86_64 platform

kitkat-x86 / jb-x86

android_x86: for x86 platform

ics-x86 / honeycomb-x86

generic_x86: for generic x86 PC/notebook

amd_brazos: for AMD Brazos platform

eeepc: for ASUS EeePC family only

asus_laptop: for some ASUS laptops

tegav2: for Tegatech Tegav2 (may work with other Atom N45x based tablets)

gingerbread-x86 / froyo-x86

generic_x86: for generic x86 PC/notebook

eeepc: for ASUS EeePC family only

asus_laptop: for some ASUS laptops

tegav2: for Tegatech Tegav2 (may work with other Atom N45x based tablets)

Actually, for historical reason, you have to use eeepc for a generic x86 PC, notebook or netbook before (includes) donut-x86 branch. Since eclair-x86 branch, eeepc is changed to serve ASUS EeePC family only. Do not use it if you are not using an EeePC.

In short, if you don't know how to choose, use eeepc for donut-x86 branch, and use generic_x86 for eclair-x86 to ics-x86 branches. But note generic_x86 is just a base for other targets. It doesn't have some advanced features like hardware acceleration.

Since jb-x86 we tried to use android_x86 as a universal target for all x86 devices. However, it may not optimized for a particular target device. If you are a developer, you can create a target based on android_x86 for your device.

If you want to add new target for your x86 device, refer to the article.

Using lunch command (recommended)

You can source the file build/envsetup.sh into your bash environment to get some shell functions to help the building:

$ . build/envsetup.sh

Now you can select a target by lunch command:

$ lunch $TARGET_PRODUCT-$TARGET_BUILD_VARIANT

where $TARGET_PRODUCT is any target described in the previous section, and possible values of $TARGET_BUILD_VARIANT are eng, user, userdebug. For example,

$ lunch android_x86-userdebug

Then you can build by m command:

$ m -jX iso_img

m command is equivalent to make, but you can use it in any subdirectory of the android-x86 tree.

Since froyo-x86, we also add menu selection to lunch command. Just type lunch, and you will get a list of available targets. Choose a target by inputting its number. Alternatively, just type lunch $number.

Building directly

To build a live cdrom iso image for target android_x86, type:

$ make iso_img TARGET_PRODUCT=android_x86

To generate a live cdrom iso for tegav2, type

$ make iso_img TARGET_PRODUCT=tegav2

Then you will get an iso file out/target/product/x86/android_x86.iso, etc.

If the computer you build on has more then one processor or core, you can take advantage of multiprocessing (or make jobs) by adding -jX to the beginning of your make command:

$ make -jX iso_img TARGET_PRODUCT=android_x86

Replace X by the number of processors you have. For example, if you have a quad core CPU, replace X with 4:

$ make -j4 iso_img TARGET_PRODUCT=android_x86

Using buildspec.mk

You can create a buildspec.mk in your android-x86 directory to remember a particular target product you build often:

With your buildspec.mk file in your android-x86 directory, you can just make by

$ make -jX iso_img

Build smaller image

Since marshmallow-x86, the generated Android-x86 core filesystem will be compressed by squashfs by default. Before that, squashfs is used only if you have squashfs-tools 4.0 (older version will not work) installed in your host. The generated iso file is much smaller (only about 30-40%). However, if you hope to disable it for some reasons, add USE_SQUASHFS=0 to make. You can put it to buildspec.mk:

USE_SQUASHFS := 0

Before froyo-x86 (included), If you hope to get a more smaller image, you may remove the debugging symbols by adding

TARGET_STRIP := 1

Since gingerbread-x86, the debugging symbols are stripped by default. Do not use this option anymore.

Testing

The generated image is located at

out/target/product/$TARGET_PRODUCT/$TARGET_PRODUCT.iso

You can easily test the iso file by a virtual box or qemu. On the booting screen, select the VESA or debug mode to boot.

Of course you can burn the iso to a CD disk and test it on a real hardware. On booting it will automatically detect your hardware and load necessary modules. If you have problem with the default frame buffer driver, you may try the VESA mode (select second item on boot screen).

Since honeycomb-x86, we supports the hybrid iso format. That is, the iso could be dumped to a usb disk directly. You may create a bootable USB disk by

$ dd if=out/target/product/x86/android_x86.iso of=/dev/sdX

where /dev/sdX is the device name of your USB disk. This feature is only available for iso files released after 2011/12/25. Note usb_img is deprecated. Do not use it anymore.

Some broken BIOS (e.g., Acer AO) is unable to boot a USB disk created in this way. If so, you may try to create bootable USB drive from the iso file by unetbootin. For both linux and windows user, here are the steps (suggested by Gregory Gee
) :

1. Download the ISO image of android-x86.
2. Download UNetbootin from http://unetbootin.sourceforge.net/ 3. Make sure you USB key is formatted. UNetbootin silently fails to work if not formated. I formatted my USB key fat32.
4. Run UNetbootin
Select your USB key as the Drive.
Select the android-x86 ISO file as the disk image.
Click ok and wait.

It should take a minute to do. If it only took UNetbootin a few seconds to copy to USB, like my first attempt, then it didn't work. So remember on future upgrades to reformat your USB key before each android install.

So now you should be able to boot from the USB key. Well, at least it worked for me. The UNetbootin is an interesting tool too.

Note androidboot.hardware= must be set to the target name of the built image.

Since kitkat-x86 the SRC= parameter may be omitted if the system image is in the same directory as the kernel.

Create /android directory in the USB disk, and copy the four files kernel initrd.img ramdisk.img system.sfs (or system.img if you set USE_SQUASHFS=0) to it.

Then you can boot from the USB disk and enjoy Android. Note all data are saved to the ramdisk, so all will lose after power off. If you hope to save data to disk, see the next section.

Install to hard disk

Install to a hard disk is just the same as install to a USB disk. Even you do not need to create a new partition. Just copy android files into an existing partition, install grub to the hard disk (if not done yet), and modify the menu.lst.

People still ask, what if my hard disk is empty? How to install grub and copy files into it? There are several ways to do it. I provide two here:

Boot from any rescue cd like systemrescuecd, and follow the instructions in the previous section.

Save data to USB/hard disk

Create a subdirectory named data in your /android directory. The user data will be directly saved to that directory. This method only works for ext3 partition.

Create a separate partition and save data to it. You have to add DATA=<device_name> to the boot option. For example, suppose your data partition is /dev/sda2, then add DATA=sda2 to the boot option.

How to solve conflicts

There are several reason to have conflicts during repo sync, say

You modify your tree locally.

The upstream changed. Since we usually keep syncing with original Android repository, sometimes we have to rebase with it. That changes the history and may cause conflicts.

In this section we assume you have conflicts due to the upstream changed. That is, you don't have local modifications. If you do, you have to solve conflicts yourself. If you follow the procedures in this section, you may lose your local modifications.

When you have resolved this problem run "git rebase --continue".If you would prefer to skip this patch, instead run "git rebase --skip".To restore the original branch and stop rebasing run "git rebase --abort".

repo sync stopped on conflicts. Since we don't have local modifications, just ignore it by git rebase --skip:

If it complains about another conflict, do git rebase --skip again, until the rebase procedure completes. Usually it is enough, but if you hope to be absolute clean, you can ignore this branch and checkout a new one:

$ git checkout -t kitkat-x86 m/kitkat-x86

This may not be the best approach to solve conflicts, but should be easy enough for beginners. If you have better suggestions, just tell us.

Customize kernel

If you'd like to customize the kernel for your hardware, read this article for details.