Setting up a chroot for Android platform development


Since Ubuntu 10.04 is still the only fully supported OS when building the Android source code (according to, you might run into trouble when trying to compile it on an OS with different versions of the tools used in the build process. This happened to me when trying to compile Android ICS (4.0.1_r1) on my Arch Linux installation. Arch Linux is a rolling distribution, which means that packages are updated continuously, and my current GCC version is 4.7.1. Ubuntu 10.04 on the other hand uses an older version of the same compiler ( This is true for most of the tools involved in the build process. One way to set up an environment that is similar to Ubuntu 10.04 is to use a chroot. In the chroot, you cannot access files or commands from outside that environment, which also means all tools needed for the build have to be installed inside the chroot, making sure non of them link to any outside libraries or files.

I will use the tools debootstrap for installing a debian base system (Ubuntu 10.04) in a chroot environment, and schroot for entering/exiting/running commands in the chroot. I will show you how to do this on Arch Linux, Gentoo and Ubuntu.


Arch Linux

Install the schroot package:

Download and build the debootstrap package from AUR (


Install the schroot and debootstrap packages:


Install the schroot and debootstrap packages:


Install Ubuntu 10.04 (Lucid) in chroot environment using debootstrap, where /path/to/chroot is the directory where you want to setup the chroot:

Wait a while…

Configure schroot

Edit /etc/schroot/schroot.conf:

Arch Linux only

Comment out networks in /etc/schroot/default/nssdatabases:

Prepare schroot for Android development

Change to schroot environment:

I get some errors I could safely ignore, e.g. E: 15binfmt: which: no update-binfmts in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin).

Update /etc/apt/sources.list (you can use to generate your own config):

Next, update apt (apt-get update && apt-get upgrade) and install the development environment according to First thing is to install Oracle JDK6, which must be downloaded from Oracle’s homepage ( One neat thing is that your home directory is actually mounted on the chroot users home directory, giving you easy access to all your user files. You can use this to simply download the Java installer to your home directory and then, in the chroot environment copying it to the target directory (e.g. /opt) and executing it:

Then install the required packages and create symlink for libGL:

After installation of tools, there is no need to be logged in as root anymore. Log out and log in as another user:

The rest of the setup process for Android source is well documented in

This Post Has 4 Comments

  1. mario

    Thanks for the tip on schroot!

  2. Sony Xperia S

    I couldn’t even successfully do it in Ubuntu :( Me, crazy n00b :( thnx for the Tut man! Will try it out :-)

  3. Hampus

    Thanks for the blog post! Worked for me in Arch Linux. Had some problems with upgrading the rsyslog package in the new system, but it all works after replacing rsyslog with syslog-ng :)

  4. joel

    This is a great tip indeed.

    Before installing the required packages, I had to create the group ‘staff’ as xml-core failed.

    # groupadd staff

Leave a Reply