Set up for AOSP development (9.0 or later)

Before you download and build the main branch of the Android source, ensure that your hardware meets the necessary requirements and that required software is properly installed. You should also be familiar with the following terms:

Git is a free and open source distributed version control system. Android uses Git for local operations such as branching, commits, diffs, and edits. For help learning Git, refer to the Git documentation.
Repo is a Python wrapper around Git that simplifies performing complex operations across multiple Git repositories. Repo doesn't replace Git for all version control operations, it only makes complex Git operations easier to accomplish.

Meet hardware requirements

Your development workstation should meet or exceed these hardware requirements:

  • A 64-bit system.

  • At least 400 GB of free disk space to check out and build the code (250 GB to check out + 150 GB to build).

  • A minimum of 64 GB of RAM. Google uses 72-core machines with 64 GB of RAM to build Android. With this hardware configuration, it takes approximately 40 minutes for a full build of Android and only a few minutes for incremental build of Android. By contrast, it takes approximately 6 hours for a full build with a 6-core machine with 64 GB of RAM.

Meet operating system requirements

Your development workstation must run any 64-bit Linux distribution with GNU C Library (glibc) 2.17 or later.

Install required packages

To build Android 11 or higher, you must use Ubuntu 18.04 or later. To install required packages for Ubuntu 18.04 or later, run the following command:

$ sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 libncurses5 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig

Among the packages installed, this command installs Git, which is used to download the AOSP source.

Install required software

Before you can work with AOSP, you must have installations of OpenJDK, Make, Python 3, and Repo. The AOSP main branch of Android comes with prebuilt versions of OpenJDK, Make, and Python 3, so additional installation steps aren't required. The following section explains how to install Repo.

Install Repo

Follow these steps to install Repo:

  1. Download the current package information:

    $ sudo apt-get update
  2. Run the following command to install the Repo launcher:

    $ sudo apt-get install repo

    The Repo launcher provides a Python script that initializes a checkout and downloads the full Repo tool.

    If successful, skip to step 4.

  3. (optional) Manually install Repo using the following series of commands:

    $ export REPO=$(mktemp /tmp/repo.XXXXXXXXX)
    $ curl -o ${REPO}
    $ gpg --recv-keys 8BB9AD793E8E6153AF0F9A4416530D5E920F5C65
    $ curl -s | gpg --verify - ${REPO} && install -m 755 ${REPO} ~/bin/repo

    The first three commands set up a temp file, download Repo to the file, and verify that the key provided matches the required key. If these commands are successful, the final command installs the Repo launcher.

  4. Verify the Repo launcher version:

    $ repo version

    The output should indicate a version of 2.5 or higher, for example:

    repo launcher version 2.40

Set an alternative output directory

By default, the output of each build is stored in the out/ subdirectory of the matching source tree. You can override this directory by exporting the OUT_DIR environment variable. For example, if you want to store your output on a different drive, you can point OUT_DIR to that drive:

$ export OUT_DIR=my_other_drive