Preface
Android AOSP compilation source code needs to be done in a Linux environment. Many students' systems are not Ubuntu, but you can use VirtualBox to install Ubuntu on Windows and Mac. This article will explain the installation process in the Windows 10 environment. The Mac environment is also similar. If If necessary, there will be a follow-up installation tutorial on Mac. In addition, you can also download Ubuntu software from the Microsoft Store under Windows 10 and give it a try.
Preparation
Equipment requirements
The computer configuration should be as high as possible. I use mac + NAS and a desktop (i7 + 1T solid state + 32G memory)
Virtual machine configuration:
CPU: It is best to keep it above 16 cores
Memory: 16G and above
Hard disk: Readers only need to compile systems below Android 7.0 to ensure that there is more than 200G of hard disk space, while Android 7.0 and above require more than 350G of hard disk space. Mechanical hard drives are also OK. The bottleneck of compilation is not IO.
(PS: This is a strict requirement, not necessary, just choose by yourself)
Software requirements
first part
Installing the Ubuntu system requires preparing two files:
1. VMware Workstantion
download address:
https://www.vmware.com/cn/products/workstation-pro/workstation-pro-evaluation.html
This is the official VM16 version. If you need VM15 or cracked version, you can use the link below (Alibaba Cloud Disk)
https://www.aliyundrive.com/s/zE1zbwQyr8F Extraction code: 60co
2. Ubuntu system:
There are instructions on the official website (https://source.android.google.cn/setup/build/initializing)
the second part
1. JDK, students who do android development will definitely configure this. If you don’t know how to configure this, learn the basics first.
2. Install the required environment software. The official directly provides online installation commands:
## Ubuntu 20.0.4版本的安装方式
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
3. Change the image source of Ubuntu to a domestic source
There are many Ubuntu image sources in China, including Alibaba's and NetEase's, as well as many education network sources, such as Tsinghua University and University of Science and Technology of China.
Here we take the source of the University of Science and Technology of China as an example to explain how to modify Ubuntu 20.04
the default source inside.
Edit /etc/apt/sources.list
the file and add the following entries at the front of the file (please make a backup before proceeding):
## 中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
Then execute the command:
sudo apt-get update
sudo apt-get upgrade
Several other domestic sources are as follows:
Aliyuan
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
163 source
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
Tsinghuayuan
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
5. Install repo
mkdir ~/bin
PATH=~/bin:$PATH
## 下载repo
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
## 并且修改它的权限
chmod a+x ~/bin/repo
6. Check whether the repo installation is complete
repo versio
#只要出现类似以下的报告即可
<repo not installed>
repo launcher version 2.15
(from /usr/bin/repo)
#
Initialize repo client
1. After installing the Repo launcher, set up your client to access the Android source code library; create an empty directory to store your working files. Give it any name you like:
mkdir yourworkName
cd yourworkName
2. Configure Git using your real name and email address. To use the Gerrit code review tool, you need an email address associated with a registered Google Account. Make sure this is a valid address where you can receive mail. The name you provide here will appear in the attribution information for the code you submit.
git config --global user.name Your Name
git config --global user.email [email protected]
3. Initialize the warehouse
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
If you need a specific Android version ( list ):
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-6.0.1_r81
Success occurs when a screen like this appears:
If it prompts that it cannot connect to gerrit.googlesource.com
This is because the repo will try to access the official git source to update itself during the running process. If you want to use tuna's mirror source to update, you can copy the following content to yours, and finally restart the terminal ~/.bashrc
.
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
4. Synchronize the source tree (you only need to execute this command to synchronize in the future)
repo sync
Since the first synchronization requires downloading approximately 95GB of data, any network failure during the process may cause synchronization failure. We strongly recommend that you use an initialization package for initialization.
Just be patient.
After the download is complete, you will see:
The installation source code is downloaded.
The next article will explain in detail how to compile the source code.