This page describes the latest information about how to build Android for x86 platform. To browse our source code, see
It is easy to compile Android for x86 platform from our git repositories. The built image should run well on real x86 devices as well as virtual machines (like qemu or virtual box). Just follow the following instructions. No additional patch is required.
Since AOSP evolves very quickly, we have created different branches corresponding to different releases of AOSP:
Firstly, refer to the AOSP page "Establishing a Build Environment" to configure your build environment. For Ubuntu 18.04, install the following required packages:
sudo apt -y install git gcc curl make repo libxml2-utils flex m4
sudo apt -y install openjdk-8-jdk lib32stdc++6 libelf-dev mtools
sudo apt -y install libssl-dev python-enum34 python-mako syslinux-utils
Then pull down the Android-x86 source tree to your working directory by:
repo init -u git://git.osdn.net/gitroot/android-x86/manifest -b $branch
repo sync --no-tags --no-clone-bundle
Where $branch is one of the branch names described in the previous section. Note the projects created or modified by android-x86 are fetched from our git server. All the other projects are still downloaded from the repositories of AOSP.
If you have issues to sync from the git protocol, try the alternative http one
repo init -u http://scm.osdn.net/gitroot/android-x86/manifest -b $branch
repo sync --no-tags --no-clone-bundle
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 section "How to Solve Conflicts" for how to solve this situation.
Note: The Android-x86 repository is very big (more than 20GB for oreo-x86). 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.
To get the source code of LineageOS (formerly CyanogenMod) porting for Android-x86, specify the manifest by an additional option -m cm.xml:
repo init -u git://git.osdn.net/gitroot/android-x86/manifest -m cm.xml -b $branch
repo sync --no-tags --no-clone-bundle
Currently the LineageOS porting is only available in nougat-x86 (cm 14.1) and marshmallow-x86 (cm 13.0) branches.
Once 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. Since nougat-x86, OpenJDK 1.8 is required.
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.
You need to choose a target for the x86 device you want to use/test. We provides several targets for different branches:
Unless you are trying to build an ancient branch, you should just use android_x86_64 for a 64-bit target, or android_x86 for a 32-bit target. They are the universal targets for all x86 devices.
Historically, you should use to use generic_x86 for eclair-x86 to ics-x86 branches. However, it may not optimized for a particular target device. Use eeepc for a generic x86 for donut-x86 branch or before, unless you have the particular devices supported by other targets.
If you are a developer, you can create a target based on android_x86 for your device. See this article for details. However, it's not recommended to do so unless you are a very experienced Android platform developer.
You can source the file build/envsetup.sh into your bash environment to get some shell functions to help the building:
Now you can select a target by lunch command:
where $TARGET_PRODUCT is any target described in the previous section, and possible values of $TARGET_BUILD_VARIANT are eng, user, userdebug. For example,
Then you can build an iso file 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. Replace X by the number of processors you have. For example, if you have a quad core CPU, replace X with 4:
m -j4 iso_img
Since froyo-x86, we also add menu selection to lunch command. Just type lunch, and you will get a list of available targets. Input the number to select a target. Alternatively, just type lunch $number.
To build an rpm file:
m -jX rpm
You need to install the rpm-build package (Fedora based distributions) or rpm package (Debian / Ubuntu based distributions) before building.The rpm file could be installed to a Linux distribution directly.
You may specify the target to be built by TARGET_PRODUCT variable. For example, to build an iso image for target android_x86, type:
make -jX iso_img TARGET_PRODUCT=android_x86
To generate a live cdrom iso for tegav2, type
make -jX iso_img TARGET_PRODUCT=tegav2
Then you will get an iso file out/target/product/x86/android_x86.iso, etc.
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 working directory, you can simply make by
make -jX iso_img
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:
Before froyo-x86 (included), If you hope to get a more smaller image, you may remove the debugging symbols by adding
Since gingerbread-x86, the debugging symbols are stripped by default. So the option is unnecessary.
The generated image is located at
You can easily test the iso file by a virtual machine like virtual box or qemu. Alternatively, on a Linux host you can use the qemu-android script (available since nougat-x86) to run android-x86 in qemu directly:
To test the image on a real x86 hardware, you can burn the iso to a compact disc (CD), then boot it on the target device. Check the manual of your vendor to see how to boot from a CD. On booting it will automatically detect your hardware and load necessary modules.
Since honeycomb-x86, we support the hybrid iso format. That is, the iso could be dumped to a usb disk directly. For example,
dd if=out/target/product/x86_64/android_x86_64.iso of=/dev/sdX
where /dev/sdX is the device name of your USB disk. The feature is available for all iso files released after 2011/12/25.
If you build an rpm file, install it to your Linux host and run the qemu-android script directly. Or reboot and choose android-x86 item from the booting menu.
For more details about how to use the iso or install it, see the installation howto.
This section describes some useful information for advanced users. You may need good linux expertise to complete it.
For advanced linux users, you may create a bootable USB disk by hand. Here are the steps:
Note androidboot.selinux=permissive must be added since nougat-x86. Besides, before marshmallow-x86, androidboot.hardware=<target> must be added to specify the target name of the built image. However, do not add this option since nougat-x86.
Since kitkat-x86 the SRC= parameter may be omitted if the system image is in the same directory as the kernel.
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 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:
We provide several ways to save data to your disk. You can choose one of them according to your situation:
mount -o remount,rw /mnt
dd bs=1M count=4096 if=/dev/zero of=/src/data.img
losetup /dev/loop6 /src/data.img
make_ext4fs -L /data /dev/loop6
losetup -d /dev/loop6
There are several reason to have conflicts during repo sync, say
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.
Here is an example of a conflict in mainfest:
repo syncremote: Counting objects: 71, done.
repo sync stopped due to conflicts. Since we don't have local modifications, just ignore it by git rebase --skip:
git rebase --skipHEAD is now at 4a4f936 add branch for local lan
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 the current branch and checkout a new one like (suppose you're using oreo-x86 branch):
git checkout -t oreo-x86 m/oreo-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.
If you'd like to customize the kernel for your hardware, read this article for details.
If you want to use IDE to develop Android-x86, maybe Intellij IDEA can be a good choice. You can follow below instructions to setup project for Intellij IDEA:
Firstly, we should build Intellij IDEA project module files:
And then we should create an empty project from Intellij IDEA, and import android.iml in the source code root directory as module to import Android-x86 code to Intellij IDEA. After loading, we can use it to view and debug source code.