C

Building an AOSP system image

Android is an open source software stack created for a wide array of devices with different form factors. Android's primary purpose is to create an open software platform available for carriers, OEMs, and developers to make their innovative ideas a reality and to introduce a successful, real-world product that improves the mobile experience for users.

Requirements

Your development workstation should meet or exceed these hardware requirements:

  • A 64-bit environment is required.
  • At least 250GB of free disk space to check out the code and an extra 150 GB to build it. If you conduct multiple builds, you need additional space.
  • If you're checking out a mirror, you need more space (over 500GB) as the full Android Open Source Project (AOSP) mirrors contain all Git repositories that have ever been used.
  • If you're running Linux, you need at least 16 GB of available RAM/swap.
  • Ubuntu 18.04 (Bionic Beaver) or the latest versions of macOS with Xcode and command line tools installed.
  • Python 2.7 or newer.
  • For Linux, install packages listed in: Setting up a Linux build environment.
  • For macOS, install packages listed in: Setting up a macOS build environment.

For more information, see Google's Build requirements documentation.

Download and Build AOSP

Working with Android code requires Git and Repo tool to be installed Download and install Repo tool from Google sources.

Initializing Repo client

After installing the Repo Launcher, set up your client to access the Android source repository:

  • Create an empty directory to hold your working files. If you're using macOS, this has to be on a case-sensitive filesystem. Give it any name you like:
    mkdir <working_dir>
    cd <working_dir>
  • Configure Git with your real name and email address. To use the Gerrit code-review tool, you need an email address that's connected with a registered Google account. Make sure that this is a live address where you can receive messages. The name that you provide here shows up in attributions for your code submissions.
    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"

    For more information, see Setting up Gerrit.

  • Run repo init to get the latest version of Repo with its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source are placed under your working directory.
    repo init -u https://android.googlesource.com/platform/manifest
  • To check out the Android Automotive 10 branch:
    repo init -u https://android.googlesource.com/platform/manifest -b android-10.0.0_r45
  • To check out a branch other than master, specify it with -b. For a list of branches, see Source code tags and builds.

A successful initialization ends 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 are kept.

Downloading the source

To download the Android source tree to your working directory from the repositories as specified in the default manifest, run:

repo sync

Build the AOSP

  • Initialize the environment with the envsetup.sh script:
    source build/envsetup.sh
  • Choose a target to build, for example:
    lunch aosp_car_x86_64-userdebug
  • Build everything with m, it can handle parallel tasks with a -jN argument. If you don't provide a -j argument the build system automatically selects a parallel task count that it thinks is optimal for your system.
  • After a successful build, run the emulator with the following command:
    emulator

Building the system image

The Android emulator allows you to run Android system images on your host as Android devices with most of their capabilities. You can also share your built Android system images so that other people can run them.

  • Make additional sdk and sdk_repo packages:
    $ make -j$(nproc) sdk sdk_repo
  • This creates the system image file under <working_dir>/out/host/linux-x86/sdk/sdk_car_x86_64:
    sdk-repo-linux-system-images-eng.[username].zip
  • Follow the instructions under Launching Android Emulator to correctly setup the system image with AVD Manager.

Available under certain Qt licenses.
Find out more.