PPrepLearn
Progress Β· 0/7 phases

πŸ”§ πŸ”§ Phase 1 β€” Prerequisites & Environment Setup

4 min read Β· Notion

Phase 1 β€” Prerequisites & Environment Setup

Duration: 2–3 weeks | Level: Foundation

You cannot learn AOSP without a working build. Get the machine ready first, then learn the theory.


πŸ“‹ Prerequisites You Must Have

Linux / Command Line

  • Comfortable with bash, grep, find, make, git
  • Understand file permissions, symlinks, environment variables
  • Know how to read a Makefile

C / C++ Basics

  • Pointers, memory management, structs
  • Compilation pipeline: preprocessor β†’ compiler β†’ linker
  • Reading .h header files
  • AOSP Framework and HAL are heavily C/C++

Java / Kotlin (you already have this βœ…)

  • Android Framework APIs are Java/Kotlin
  • Android System Services are written in Java

Git

  • git log, git diff, git cherry-pick, git rebase
  • AOSP uses repo tool (a wrapper around multiple git repos)

πŸ–₯️ Machine Requirements

RequirementMinimumRecommended
OSUbuntu 20.04 LTSUbuntu 22.04 LTS
RAM16 GB32–64 GB
Disk250 GB free500 GB SSD
CPU8 cores16+ cores
Build time~3–5 hours~1–2 hours

⚠️ macOS is officially unsupported for building recent AOSP versions. Use Linux or a Linux VM/WSL2.


βš™οΈ Environment Setup Steps

Step 1 β€” Install build dependencies

sudo apt-get update
sudo apt-get install -y git-core gnupg flex bison build-essential \
  zip curl zlib1g-dev libc6-dev-i386 libncurses5 \
  lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev \
  libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig \
  python3 python-is-python3 openjdk-11-jdk

Step 2 β€” Install repo tool

mkdir -p ~/.bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+x ~/.bin/repo
export PATH="${HOME}/.bin:${PATH}"

Step 3 β€” Initialize AOSP source

mkdir ~/aosp && cd ~/aosp
repo init -u https://android.googlesource.com/platform/manifest \
  -b android-14.0.0_r1   # pick a stable branch
repo sync -c -j$(nproc) --force-sync --no-clone-bundle
# This downloads ~100 GB. Leave it overnight.

Step 4 β€” Set up build environment

cd ~/aosp
source build/envsetup.sh
lunch aosp_x86_64-eng   # for emulator
# or: lunch aosp_arm64-eng

Step 5 β€” Build AOSP

m -j$(nproc)   # full build β€” takes 1–5 hours
# Incremental: m -j$(nproc) framework

Step 6 β€” Run on emulator

emulator &

πŸ“ AOSP Source Tree β€” First Look

aosp/
β”œβ”€β”€ art/          # Android Runtime (ART) β€” Java bytecode execution
β”œβ”€β”€ bionic/       # Android's C library (replaces glibc)
β”œβ”€β”€ build/        # Build system (Soong + Make)
β”œβ”€β”€ device/       # Device-specific configs
β”œβ”€β”€ frameworks/   # Android Framework (Java APIs, System Services)
β”‚   β”œβ”€β”€ base/     # Core framework β€” AMS, WMS, PMS, etc.
β”‚   └── native/   # Native framework (SurfaceFlinger, etc.)
β”œβ”€β”€ hardware/     # HAL interfaces and implementations
β”œβ”€β”€ kernel/       # Linux kernel
β”œβ”€β”€ packages/     # Built-in apps (Settings, SystemUI, etc.)
β”œβ”€β”€ system/       # Low-level system (init, vold, netd)
β”œβ”€β”€ vendor/       # OEM/vendor-specific code
└── external/     # Third-party open-source libs

πŸ› οΈ Key Tools to Learn

ToolPurpose
repoManage multi-git AOSP workspace
lunchSelect build target (device + variant)
m / mm / mmmBuild entire tree / current module / specific module
adbConnect to device/emulator, push/pull files
fastbootFlash system partitions
logcatView system logs
Android StudioBrowse AOSP source with indexing
OpenGrokWeb-based AOSP code search (cs.android.com)

βœ… Phase 1 Checklist

  • Ubuntu machine or VM ready with 250 GB+ free
  • All build dependencies installed
  • repo tool installed
  • AOSP source synced (android-14 branch)
  • source build/envsetup.sh && lunch working
  • Full AOSP build completed (m)
  • Emulator launches successfully
  • Can adb shell into the emulator
  • Familiar with top-level directory structure
  • Can use cs.android.com to search source code
  • Read a simple Android.bp build file
  • Made a trivial code change + incremental build

Related