Article Directory
1. Environment preparation
1.1 Basic Information
resource | Version |
---|---|
operating system | Ubuntu Desktop 18.04 |
Official source address | https://android.googlesource.com/platform/manifest |
Domestic mirror address | https://aosp.tuna.tsinghua.edu.cn/platform/manifest |
Android version | android-13.0.0_r18 |
disk space | 400G |
machine memory | 16G |
1.2 System initialization
1.2.1 Updating Ubuntu packages
su - root
apt-get update
apt-get upgrade
1.2.2 Install the git tool
sudo apt-get install git
1.2.3 Install dependency packages (Ubuntu 18.04)
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig vim
1.2.4 Modify the default python version
su - root
rm -rf /usr/bin/python
ln -s /usr/bin/python3 /usr/bin/python
Verify the python version and confirm that the default version of python is 3.x
python --version
1.2.5 Install repo tools
cd /opt
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
Modify the value of the REPO_URL variable in the repo. Set the variable value to:https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
vim repo
Then copy the repo files into /usr/bin
the directory
su - root
cp repo /usr/bin
chmod +x /usr/bin/repo
2. The source code download is complete
2.1 Create source directory
su - root
cd /opt
mkdir android
cd android
2.2 Initialize the source code warehouse
- Configure git information
git config --global user.email "email"
git config --global user.name "name"
- Initialize the source repository
export GIT_SSL_NO_VERIFY=1
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-13.0.0_r18
2.3 Start to download the source code
repo sync -c -j8
Wait for the download to complete.
It takes a long time to download the source code, taking a total of 1 hour and 12 minutes. After the source code is downloaded to the local, it will automatically enter the file inspection stage to check whether the downloaded file is missing or not.
Notes on source code download
- The download interruption may cause some packages to fail to be successfully obtained, as shown in the figure below
. If you encounter the information in the figure above, it means that the source code download failed and you need to download it again. Since the source code download takes a long time, it is recommended to turn off the sleep function of the computer, otherwise the download may be interrupted when the computer sleeps.
2.4 Android 13 source directory
After the source code is downloaded, it occupies about 126G of disk space.
3. Build the Android system
3.1 Switch dash to bash
sudo dpkg-reconfigure dash
Select No, it will switch to the bash environment
3.2 Install JDK
sudo apt-get install openjdk-11-jdk
3.2 Start building
source build/envsetup.sh
3.3 Select build target
lunch
3.4 Build target platform image
m -j8
It will enter the system compilation and construction process.
The Android system construction process is very long. After the construction is completed, you will see the compiled system image in the out directory.