Windows11 VMware-Ubuntu-Android13 source code download and full compilation
Friends who want to use Mac to compile source code can basically give up the idea. I tried various compatibility errors and had to use Windows to install VMware + Ubuntu.
1. Hardware configuration
My configuration of Windows 11 notebook: 32G + 1.5T, it is best to use a 32G + 1T SSD machine (no pressure). It is
recommended that the machine hardware condition is at least 16G memory + 300G free disk. I have used a VMware disk with 274G free disk. The download is a bit tight.
Official recommended configuration , I have selected a few key points and listed them.
Hardware
- The memory should be at least 16GB, and the actual test recommends at least 32G.
- The disk must be at least 250GB, and actual testing recommends at least 512G.
Software
- It is recommended to use Ubuntu 18.04 (Bionic Beaver) , Docker, Linux
- Starting June 22, 2021, building on Windows or MacOS will no longer be supported.
- From January 1, 2020, python2 is no longer supported, please use python3
2. Software environment
- VMware-workstation-full-16.2.4-20089737.exe (file 615MB)
- UbuntuOS-v18.04-desktop-amd64.iso (file 1.78G)
3. Install Ubuntu on VMware suitable for downloading and compiling Android12 source code
Another tutorial address: Installing Ubuntu on VMware suitable for downloading and compiling Android12 source code
VMWare-Workstation download address
For ease of operation, after installing Ubuntu, log in and switch to the root user
Set the root user password (you can set a simple password), and switch users (direct switching without setting a password will report: su: Authentication failure)
sudo passwd root
su root
xxx
4. Tool download
Install dependencies:
apt-get 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 ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
Install common tools:
repo: apt-get install repo
curl: apt-get install curl
vim: apt-get install vim
git: apt-get install git
配置git用户
git config --global user.name 'xxx'
git config --global user.email '[email protected]'
jdk-11: apt-get install openjdk-11-jdk
python: apt-get install python
(python3 should be installed by default, or use python3 directly)
5. Source code environment
mkdir ~/bin
PATH=~/bin:$PATH #直接配置全局环境变量也行
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod +x ~/bin/repo
mkdir ~/AOSP_13
6. Download
First, clearly download the branch. What I downloaded here is android-13.0.0_r7 , because this branch supports all mainstream pixel models.
1. Download the image and replace it with Tsinghua source
cd ~/AOSP_13
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
2. Initialize the warehouse and specify branches. For more branches, check the official code name and branch version number.
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-13.0.0_r7
Encountered an SSL error:
server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
Just turn off git's SSL verification, and then re-execute the repo initialization command.
git config --global http.sslverify false
Another command error encountered:
env: python: No such file or directory
the reason is/usr/bin/pythonIf it does not exist, it may be linked to python2. If it is already linked to python3, you can skip this step.
The first line of the repo script is defined like this
So there are two ways to solve it:
- Modify the first line to define python in the script to python3
vim ~/bin/repo
- Use dynamic linking to link /usr/bin/python3 to the /usr/bin/python script
rm -f /usr/bin/python
ln -s /usr/bin/python3 /usr/bin/python
Execute the repo initialization command again
After this step is successfully executed, repo
it is initialized. There is already a .repo
folder in the current directory. This directory stores configurations such as lists.
3. Start downloading the code synchronously: It took about 10 hours to download all the files.
-j specifies the number of threads. If you use the HKUST mirror source, be careful not to set it too large. If there is a limit, it will fail.
time repo sync -j8 #指定线程数为8
time can be used for timing
4. Download completed
The process was interrupted several times by Ctrl + C, so the time was not accurate and is for reference only. Anyway, I just left it downloading all night.
正在更新文件: 100% (16294/16294), 完成.
正在更新文件: 100% (1904/1904), 完成.m/prebuilts/maven_repo/android正在更新文件: 61% (1162/1904)
正在更新文件: 100% (18247/18247), 完成.
Checking out: 100% (1052/1052), done in 6m48.098s
root@ubuntu:~/AOSP_13#
root@ubuntu:~/AOSP_13# repo sync -j8
Fetching: 100% (1052/1052), done in 3m12.343s
Garbage collecting: 100% (1052/1052), done in 7.501s
Checking out: 100% (1052/1052), done in 47.189s
repo sync has finished successfully.
root@ubuntu:~/AOSP_13#
root@ubuntu:~/AOSP_13#
This is a screenshot near the end of downloading
The source code directory after downloading is as follows:
There is one less compatibility directory than the Android12 version. For more details, you can check it out at http://aospxref.com
7. Compile
- Initialize the compilation environment
- Use the command to compile (warnings that occur during the process will not be affected, do not interrupt execution manually)
# 1. 初始化编译环境
source build/envsetup.sh
# 2.方式一: 到需要编译的目录下执行命令 mm
mm
# 2.方式二: 指定需要编译目录下 Android.bp 里定义的 name 进行编译
# 例如编译 framework.jar: frameworks/base/Android.bp
make framework-minus-apex
The definition of framework in frameworks/base/Android.bp since Android10 version
java_library {
name: "framework-minus-apex",
defaults: ["framework-minus-apex-defaults"],
installable: true,
// For backwards compatibility.
stem: "framework",
apex_available: ["//apex_available:platform"],
visibility: [
"frameworks/base",
// TODO(b/147128803) remove the below lines
"//frameworks/base/apex/appsearch/framework",
"//frameworks/base/apex/blobstore/framework",
"//frameworks/base/apex/jobscheduler/framework",
"//frameworks/base/packages/Tethering/tests/unit",
"//packages/modules/Connectivity/Tethering/tests/unit",
]
}
The directory I need to compile:
framework.jar ---------------- frameworks/base/(实际目录 base/core/java/)
telephony-common.jar --------- frameworks/opt/telephony(实际目录 base/telephony)
The corresponding output path after compilation:
out/target/common/obj/JAVA_LIBRARIES/framework-minus-apex_intermediates/classes.jar
out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar
It takes about twenty minutes to compile these two directories. This is a Windows11 (AMD R5700 + 16G + 512G) compiling the Android12 version.
In addition, I performed the full editing of mm on this machine (the configuration is shown at the beginning of the article) , which was very time-consuming:3 hours, 25 minutes and 48 seconds, but I didn’t turn on the high-frequency mode, otherwise the time should be shorter.
Start full compilation
It is strongly recommended not to run it on a machine with less than 32G of memory. My memory is full, otherwise it will too affect the operating experience of other software. I left the browser for too long, and the memory was tight and my tag resources were recycled, causing me to refill. The content modified in the afternoon (this article is updated from Android 12 version to 13)
Finally!!! All compiled