Set up repo
From Google
| 12
 3
 4
 
 | mkdir ~/binPATH=~/bin:$PATH
 curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
 chmod a+x ~/bin/repo
 
 | 
From Tsinghua
| 12
 3
 4
 
 | mkdir ~/binPATH=~/bin:$PATH
 curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
 chmod a+x ~/bin/repo
 
 | 
For version 1.25, the SHA-256 checksum for Repo is d06f33115aea44e583c8669375b35aad397176a411de3461897444d247b6c220.
For version 1.26, the SHA-256 checksum for Repo is 0cf5f52bcafb8e1d3ba0271b087312f6117b824af272bedd4ee969d52363a86b.
Config git
| 12
 
 | git config --global user.name "Your Name"git config --global user.email "[email protected]"
 
 | 
Download Source Code
AOSP
Check Build Name: https://source.android.com/setup/start/build-numbers#source-code-tags-and-builds
| 12
 3
 
 | repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r47
 repo sync
 
 | 
Kernel
| 12
 3
 
 | repo init -u https://android.googlesource.com/kernel/manifest -b BRANCHrepo init -u https://aosp.tuna.tsinghua.edu.cn/kernel/goldfish -b android-4.14
 repo sync
 
 | 
For older version:
| 12
 3
 
 | git clone https://android.googlesource.com/kernel/goldfishgit checkout -a
 git checkout -b branch_name
 
 | 
AOSP
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r47
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r47
Kernel
repo init -u https://aosp.tuna.tsinghua.edu.cn/kernel/manifest -b common-android-mainline
Build
Docker Config
Project Structure
| 12
 3
 4
 5
 6
 7
 
 | ├── android│   ├── aosp
 │   ├── bin
 │   └── kernel
 └── build_aosp
 ├── Dockerfile
 └── sources.list
 
 | 
Dockerfile
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 
 | FROM ubuntu:18.04
 WORKDIR /root/
 ENV PATH ~/bin:$PATH
 ENV TERM xterm
 ENV DEBIAN_FRONTEND noninteractive
 
 COPY sources.list /etc/apt/sources.list
 RUN apt-get update && apt-get install -y --no-install-recommends apt-utils && apt-get install -y ca-certificates
 RUN sed -i 's/http:\/\/mirrors.tuna.tsinghua.edu.cn/https:\/\/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
 RUN apt-get update && apt-get -y install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip
 
 | 
Build
| 12
 3
 4
 5
 6
 7
 8
 
 | docker build -t build_aosp ./build_aospdocker build --no-cache=true build_aosp ./build_aosp
 docker run -it -v ~/android:/root build_aosp /bin/bash
 
 source build/envsetup.sh
 m help
 m
 
 
 |