Building the Android Open Source Project from scratch is one of the most computationally intense software compilation processes in the world. It requires a highly specific environment and immense hardware power. Before you can even begin downloading the source code, you must properly configure your host machine.
Supported Operating Systems
While it is technically possible to build Android on macOS or via Windows Subsystem for Linux (WSL2), it is extremely highly discouraged for serious development. The AOSP build system (Soong and Ninja) is primarily designed, tested, and optimized exclusively for Linux.
Specifically, Google officially supports Ubuntu LTS (Long Term Support) releases.
- If you are building modern Android (Android 11 through Android 15), Ubuntu 20.04 LTS or Ubuntu 22.04 LTS are the industry standards.
- Older versions of Android (like Android 8.0) may strictly require older Ubuntu versions like 14.04 or 16.04 due to deprecated compiler dependencies.
You can verify your current Ubuntu version via the terminal:
lsb_release -a
Hardware Requirements
Attempting to build AOSP on a standard consumer laptop will likely result in out-of-memory crashes or build times exceeding 24 hours. A professional AOSP build environment requires a dedicated workstation or a high-performance cloud server.
1. Storage (Disk Space)
Storage is typically the first bottleneck developers hit.
- Source Code: The raw source code for a single branch of AOSP takes up approximately 250GB.
- Build Output: The output directory (
out/) generated during a full build will consume an additional 150GB to 200GB. - Total Requirement: You need a minimum of 400GB of free disk space just to compile one version of Android. If you plan to use
ccache(Compiler Cache) to speed up future builds, you should allocate at least 500GB. - Disk Speed: A fast NVMe SSD is absolutely mandatory. Building on a mechanical HDD is virtually impossible.
2. Memory (RAM)
The build system utilizes heavily parallelized compilation. If you run out of RAM, the Linux Out-Of-Memory (OOM) killer will terminate your compiler mid-build.
- Minimum: 16GB of RAM (You will likely need to configure a massive swap file to prevent crashes, and compilation will be slow).
- Recommended: 32GB of RAM.
- Optimal: 64GB of RAM or higher (Standard for professional AOSP engineers).
Check your available memory via the terminal:
free -h
3. CPU
More cores equate directly to faster build times.
- A modern 16-core or 32-core processor (like an AMD Threadripper or high-end Intel Xeon) can compile AOSP in under an hour.
- A standard 4-core laptop might take 8 to 12 hours.
Setting Up the Workspace
Once your Ubuntu environment is running, it is heavily recommended to dedicate a specific directory on your fastest storage drive to your workspace.
mkdir ~/aosp-workspace
cd ~/aosp-workspace
This isolated directory will contain your .repo hidden folder, the raw source code, and all generated build artifacts. Do not place this directory inside a cloud-synced folder (like Dropbox or Google Drive), as the sheer number of files (over 2 million) will instantly crash the syncing client.