Based on Ubuntu 22.04
Until 2024-06-07, The latest AOSP version is android-14.
Assume we have downloaded the AOSP codebase to the /aosp_src directory with repo on the host machine.
Refer to Download the Android source or AOSP Mirror Help for further help.
The official AOSP build env is maintained on X86_64 platform only, so we specify the --platform option regardless of the host platform.
Now we build the docker image named aosp-build.
docker build --platform linux/amd64 -t aosp-build:latest -f Dockerfile .NOTE, until 2024.6, there may be a rosetta bug on MacOS with Apple Chip M2 and M3, so we may have to disable rosetta in Docker Desktop → Settings → General.
Run a container named aosp of the aosp-build image with -h, -v and -w options.
docker run --platform linux/amd64 --rm -d --name -m 16g aosp -h aosp -v /aosp_src:/aosp -w /aosp aosp-buildNote, the default memory limit of Docker Desktop is 8GB, but more than 16GB is required to build the AOSP, enlarge the limit before run the container:
Docker Desktop → Settings → Resources → Memory limit
docker exec -it aosp /bin/bash./helper build./helper run ../android-14.0.0_r1./helper bash./helper stop./helper clean