美文网首页
编译Android系统源码

编译Android系统源码

作者: 今天i你好吗 | 来源:发表于2023-09-15 23:37 被阅读0次

参考资料:
https://www.jianshu.com/p/5eaec7be3da7
官网地址: https://source.android.google.cn/docs/setup/start?hl=zh-cn
分支: https://source.android.google.cn/docs/setup/about/build-numbers?hl=zh-cn#source-code-tags-and-builds

Google官方推荐使用Ubuntu 18.04系统进行编译(Ubuntu 22.04.3 LTS也可以,需要更高的内存)
https://source.android.google.cn/docs/setup/start/requirements?hl=zh-cn#os
至少需要 16 GB 的可用 RAM, 磁盘空间300G以上.
最好用固态硬盘,不建议用机械硬盘,尤其是还要配置虚拟内存的
内存为16G时需要配虚拟内存,24G可以不用配(编译过程中系统内存占用最高可以达到23G以上)

android-13.0.0_r24分支为例: 代码136G左右, 编译后增加100G左右,还有系统占用等

编译案例:
i5 4590 24G电脑, 分配虚拟机4核20G, 2块机械硬盘组建的RAID 0存放虚拟硬盘,没有编译成功. (编译失败时可以再次执行m继续编译,且编译成功的部分不会再重新编译) (内存增加到24G后耗时10多小时编译成功, 中途未出现过失败重试)
i7 9750H 32G电脑, 分配虚拟机8核24G, 虚拟机磁盘放固态硬盘可以编译成功且中途无失败重新编译, 耗时4小时左右(装Ubuntu22配虚拟内存中途失败几次才编译成功).
i7 9750H 32G电脑, 分配虚拟机8核24G, 虚拟机通过smb加载2块机械硬盘组建的RAID 0存放的虚拟硬盘, 重试多次编译可以编译成功

image.png

1.环境搭建

创建Ubuntu 18.04虚拟机


gif4.gif

2.安装git并配置用户名和邮箱

sudo apt-get update    //先更新下apt-get
sudo apt-get install git    //安装git
git --version    //查看git版本
git config --global user.name 用户名  //配置用户名
git config --global user.email 用户邮箱    //配置邮箱
image.png image.png

3.把python默认指向python3(repo需要用到)

sudo update-alternatives --install  /usr/bin/python python /usr/bin/python3  3
sudo update-alternatives --config python    //切换Python版本, 不用执行
image.png

4.安装repo

不建议使用sudo apt-get install repo安装, 可能安装的较低版本的,不支持python3

//创建bin,并加入到PATH中
mkdir ~/bin
PATH=~/bin:$PATH
sudo apt-get install curl    //安装curl库
//下载repo并设置权限
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
repo version    //查看repo版本
错误演示 image.png

5.下载源码

示例下载的是android-13.0.0_r24 分支源码, 更多分支: 源代码标记和 build 对应"标记"列

mkdir ~/Desktop/aosp    //在桌面创建个aosp文件夹存放源码
cd ~/Desktop/aosp    //进入aosp文件夹
//下载android-13.0.0_r24分支源码, 可能出现无法连接到 gerrit.googlesource.com, 解决方案见下文
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-13.0.0_r24
repo sync    //同步源码树(真正下载源代码,下载后占用136G左右,需要等很久)

如果提示无法连接到 gerrit.googlesource.com,可以编辑 sudo gedit ~/bin/repo 把 REPO_URL 一行替换成: REPO_URL = 'https://gerrit-googlesource.proxy.ustclug.org/git-repo'

image.png image.png image.png image.png

6.编译

source build/envsetup.sh    //初始化环境
lunch sdk_phone_x86_64    //选择需要构建的产品,当前构建的是sdk_phone_x86_64即AVD 系统映像
m    //构建代码(i7 9750H给虚拟机配8核24G,固态硬盘,耗时4小时左右)

官网编译介绍地址 , AVD 系统映像? , 其它编译命令

image.png image.png

7.启动构建的模拟器

构建流程会自动将模拟器添加到您的路径中。如需运行模拟器,请输入以下命令:

emulator    //启动构建的模拟器

//如果出现ProbeKVM: This user doesn't have permissions to use KVM (/dev/kvm).
sudo chmod -R 777 /dev/kvm    //添加权限后重新执行emulator
image.png

8.执行日志

下载代码相关部分

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ sudo apt-get update
[sudo] password for yzh: 
Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]   
Get:4 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease [83.3 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [76.9 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [296 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [62.5 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:9 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [303 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Get:11 http://us.archive.ubuntu.com/ubuntu bionic-backports/main amd64 DEP-11 Metadata [8,136 B]
Get:12 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [10.0 kB]
Fetched 1,023 kB in 3s (351 kB/s)                                           
Reading package lists... Done
yzh@ubuntu:~$ 
yzh@ubuntu:~$ sudo apt-get install git 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fonts-liberation2 fonts-opensymbol gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gir1.2-gudev-1.0 gir1.2-udisks-2.0 grilo-plugins-0.3-base gstreamer1.0-gtk3
  libboost-date-time1.65.1 libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-locale1.65.1 libcdr-0.1-1 libclucene-contribs1v5 libclucene-core1v5
  libcmis-0.5-5v5 libcolamd2 libdazzle-1.0-0 libe-book-0.1-1 libedataserverui-1.2-2 libeot0 libepubgen-0.1-1 libetonyek-0.1-1 libevent-2.1-6 libexiv2-14
  libfreerdp-client2-2 libfreerdp2-2 libgc1c2 libgee-0.8-2 libgexiv2-2 libgom-1.0-0 libgpgmepp6 libgpod-common libgpod4 liblangtag-common liblangtag1 liblirc-client0
  liblua5.3-0 libmediaart-2.0-0 libmspub-0.1-1 libodfgen-0.1-1 libqqwing2v5 libraw16 librevenge-0.0-0 libsgutils2-2 libssh-4 libsuitesparseconfig5 libvncclient1
  libwinpr2-2 libxapian30 libxmlsec1-nss lp-solve media-player-info python3-mako python3-markupsafe syslinux syslinux-common syslinux-legacy usb-creator-common
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 285 not upgraded.
Need to get 4,817 kB of archives.
After this operation, 34.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 liberror-perl all 0.17025-1 [22.8 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 git-man all 1:2.17.1-1ubuntu0.18 [804 kB]
7% [2 git-man 2,541 B/804 kB 0%]
Get:3 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 git amd64 1:2.17.1-1ubuntu0.18 [3,990 kB]
Fetched 4,817 kB in 3s (1,763 kB/s)
Selecting previously unselected package liberror-perl.
(Reading database ... 151189 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17025-1_all.deb ...
Unpacking liberror-perl (0.17025-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.17.1-1ubuntu0.18_all.deb ...
Unpacking git-man (1:2.17.1-1ubuntu0.18) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.17.1-1ubuntu0.18_amd64.deb ...
Unpacking git (1:2.17.1-1ubuntu0.18) ...
Setting up git-man (1:2.17.1-1ubuntu0.18) ...
Setting up liberror-perl (0.17025-1) ...
Setting up git (1:2.17.1-1ubuntu0.18) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ git --version
git version 2.17.1
yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ git config --global user.name
yzh@ubuntu:~$ 
yzh@ubuntu:~$ git config --global user.email
yzh@ubuntu:~$ 
yzh@ubuntu:~$ git config --global user.name yzh
yzh@ubuntu:~$ 
yzh@ubuntu:~$ git config --global user.name
yzh
yzh@ubuntu:~$ 
yzh@ubuntu:~$ git config --global user.email yzh@yyds.com
yzh@ubuntu:~$ 
yzh@ubuntu:~$ git config --global user.email
yzh@yyds.com
yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ python

Command 'python' not found, but can be installed with:

sudo apt install python3       
sudo apt install python        
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.

yzh@ubuntu:~$ 
yzh@ubuntu:~$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ whereis python3
python3: /usr/bin/python3.6 /usr/bin/python3 /usr/bin/python3.6m /usr/lib/python3.7 /usr/lib/python3.6 /usr/lib/python3.8 /usr/lib/python3 /etc/python3.6 /etc/python3 /usr/local/lib/python3.6 /usr/include/python3.6m /usr/share/python3 /usr/share/man/man1/python3.1.gz
yzh@ubuntu:~$ 
yzh@ubuntu:~$ sudo update-alternatives --install  /usr/bin/python python /usr/bin/python3  3
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode
yzh@ubuntu:~$ 
yzh@ubuntu:~$ python
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ sudo update-alternatives --config python
There is only one alternative in link group python (providing /usr/bin/python): /usr/bin/python3
Nothing to configure.
yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ mkdir ~/bin
yzh@ubuntu:~$ PATH=~/bin:$PATH
yzh@ubuntu:~$ 
yzh@ubuntu:~$ sudo apt-get install curl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fonts-liberation2 fonts-opensymbol gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gir1.2-gudev-1.0 gir1.2-udisks-2.0 grilo-plugins-0.3-base gstreamer1.0-gtk3
  libboost-date-time1.65.1 libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-locale1.65.1 libcdr-0.1-1 libclucene-contribs1v5 libclucene-core1v5
  libcmis-0.5-5v5 libcolamd2 libdazzle-1.0-0 libe-book-0.1-1 libedataserverui-1.2-2 libeot0 libepubgen-0.1-1 libetonyek-0.1-1 libevent-2.1-6 libexiv2-14
  libfreerdp-client2-2 libfreerdp2-2 libgc1c2 libgee-0.8-2 libgexiv2-2 libgom-1.0-0 libgpgmepp6 libgpod-common libgpod4 liblangtag-common liblangtag1 liblirc-client0
  liblua5.3-0 libmediaart-2.0-0 libmspub-0.1-1 libodfgen-0.1-1 libqqwing2v5 libraw16 librevenge-0.0-0 libsgutils2-2 libssh-4 libsuitesparseconfig5 libvncclient1
  libwinpr2-2 libxapian30 libxmlsec1-nss lp-solve media-player-info python3-mako python3-markupsafe syslinux syslinux-common syslinux-legacy usb-creator-common
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libcurl4
The following NEW packages will be installed:
  curl libcurl4
0 upgraded, 2 newly installed, 0 to remove and 285 not upgraded.
Need to get 379 kB of archives.
After this operation, 1,059 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.24 [221 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 curl amd64 7.58.0-2ubuntu3.24 [159 kB]
Fetched 379 kB in 2s (202 kB/s)
Selecting previously unselected package libcurl4:amd64.
(Reading database ... 152096 files and directories currently installed.)
Preparing to unpack .../libcurl4_7.58.0-2ubuntu3.24_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.24) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.58.0-2ubuntu3.24_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3.24) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.24) ...
Setting up curl (7.58.0-2ubuntu3.24) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.4) ...
yzh@ubuntu:~$ 
yzh@ubuntu:~$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 44471  100 44471    0     0   126k      0 --:--:-- --:--:-- --:--:--  126k
yzh@ubuntu:~$ chmod a+x ~/bin/repo
yzh@ubuntu:~$ 
yzh@ubuntu:~$ repo version
<repo not installed>
repo launcher version 2.36
       (from /home/yzh/bin/repo)
git 2.17.1
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0]
OS Linux 5.4.0-150-generic (#167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023)
CPU x86_64 (x86_64)
Bug reports: https://issues.gerritcodereview.com/issues/new?component=1370071
yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ mkdir ~/Desktop/aosp
yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ 
yzh@ubuntu:~$ cd  ~/Desktop/aosp
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-13.0.0_r24
Downloading Repo source from https://gerrit.googlesource.com/git-repo
fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 111] Connection refused
fatal: double check your --repo-rev setting.
fatal: cloning the git-repo repository failed, will remove '.repo/repo' 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ whereis repo
repo: /home/yzh/bin/repo
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ sudo gedit ~/bin/repo

** (gedit:4655): WARNING **: 19:57:27.499: Set document metadata failed: Setting attribute metadata::gedit-spell-language not supported

** (gedit:4655): WARNING **: 19:57:27.499: Set document metadata failed: Setting attribute metadata::gedit-encoding not supported

** (gedit:4655): WARNING **: 20:02:43.110: Set document metadata failed: Setting attribute metadata::gedit-position not supported
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-13.0.0_r24
Downloading Repo source from https://gerrit-googlesource.proxy.ustclug.org/git-repo
repo: Updating release signing keys to keyset ver 2.3

Your identity is: yzh <yzh@yyds.com>
If you want to change this, please re-run 'repo init' with --config-name

Testing colorized output (for 'repo diff', 'repo status'):
  black    red      green    yellow   blue     magenta   cyan     white 
  bold     dim      ul       reverse 
Enable color display in this user account (y/N)? 

repo has been initialized in /home/yzh/Desktop/aosp
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ repo sync
remote: Enumerating objects: 81748, done.
remote: Counting objects: 100% (7290/7290), done.
remote: Compressing objects: 100% (1402/1402), done.
remote: Total 81748 (delta 6395), reused 5785 (delta 5581), pack-reused 74458
Fetching:  4% (52/1134) 3:24 | 4 jobs | 0:46 device/google/pantah-kernel @ device/google/pan..

----------------------------------分割线, 代码同步成功后--------------------------------

yzh@ubuntu:~/Desktop/aosp$ repo sync
remote: Enumerating objects: 81748, done.
remote: Counting objects: 100% (7290/7290), done.
remote: Compressing objects: 100% (1402/1402), done.
remote: Total 81748 (delta 6395), reused 5785 (delta 5581), pack-reused 74458
Fetching: 100% (1134/1134), done in 53m8.127s
Checking out files: 100% (6786/6786), done.
Checking out files: 100% (541/541), done.
Checking out files: 100% (9228/9228), done.
Checking out files: 100% (3546/3546), done.
Checking out files: 100% (9640/9640), done.
Checking out files: 100% (1007/1007), done.
Checking out files: 100% (2350/2350), done.
Checking out files: 100% (1115/1115), done.
Checking out files: 100% (3061/3061), done.
Checking out files: 100% (603/603), done.
Checking out files: 100% (994/994), done.
Checking out files: 100% (170/170), done.
Checking out files: 100% (3365/3365), done.
Checking out files: 100% (1874/1874), done.
Checking out files: 100% (847/847), done.
Checking out files: 100% (1180/1180), done.
Checking out files: 100% (639/639), done.
Checking out files: 100% (10926/10926), done.
Checking out files: 100% (255/255), done.
Checking out files: 100% (1065/1065), done.
Checking out files: 100% (74/74), done. 
Checking out files: 100% (124/124), done.
Checking out files: 100% (199/199), done.
Checking out files: 100% (364/364), done.
Checking out files: 100% (1559/1559), done.
Checking out files: 100% (3440/3440), done.
Checking out files: 100% (405/405), done.
Checking out files: 100% (344/344), done.
Checking out files: 100% (2238/2238), done.
Checking out files: 100% (818/818), done.
Checking out files: 100% (1133/1133), done.
Checking out files: 100% (391/391), done.
Checking out files: 100% (737/737), done.
Checking out files: 100% (1972/1972), done.al/cbor-javaChecking out files:  72% (1427/1972)   
Checking out files: 100% (3021/3021), done.
Checking out files: 100% (7408/7408), done.
Checking out files: 100% (415/415), done.
Checking out files: 100% (9/9), done.  ternal/androidplotChecking out files:  57% (14115/24471)   
Checking out files: 100% (1787/1787), done.
Checking out files: 100% (3013/3013), done.
Checking out files: 100% (1466/1466), done.
Checking out files: 100% (12660/12660), done.
Checking out files: 100% (62/62), done.  
Checking out files: 100% (24471/24471), done.
Checking out files: 100% (11676/11676), done.
Checking out files: 100% (4887/4887), done.
Checking out files: 100% (138/138), done.
Checking out files: 100% (2241/2241), done.
Checking out files: 100% (866/866), done.
Checking out files: 100% (713/713), done.
Checking out files: 100% (4828/4828), done.
Checking out files: 100% (8198/8198), done.
Checking out files: 100% (734/734), done./redbullChecking out files:  96% (705/734)   
Checking out files: 100% (1153/1153), done.edbull-sepolicyChecking out files:  51% (589/1153)   
Checking out files: 100% (910/910), done.
Checking out files: 100% (16/16), done.
Checking out files: 100% (3378/3378), done.
Checking out files: 100% (6999/6999), done.
Checking out files: 100% (1667/1667), done.
Checking out files: 100% (271/271), done.ernal/go-cmpChecking out files:   4% (461/9703)   
Checking out files: 100% (9703/9703), done.
Checking out files: 100% (205/205), done.
Checking out files: 100% (6540/6540), done.
Checking out files: 100% (36/36), done.  
Checking out files: 100% (11231/11231), done.
Checking out files: 100% (1526/1526), done.
Checking out files: 100% (1143/1143), done.
Checking out files: 100% (9543/9543), done.
Checking out files: 100% (117/117), done.
Checking out files: 100% (516/516), done.
Checking out files: 100% (2621/2621), done.
Checking out files: 100% (3106/3106), done.
Checking out files: 100% (708/708), done.ic/mini-emulator-arm64Checking out files:  99% (704/708)   
Checking out files: 100% (4620/4620), done./qemuChecking out files:  55% (2542/4620)   
Checking out files: 100% (125/125), done.
Checking out files: 100% (2234/2234), done.
Checking out files: 100% (3186/3186), done.nal/deqp-deps/amberChecking out files: 100% (3186/3186)   
Checking out files: 100% (16102/16102), done.l/google-benchmarkChecking out files:  99% (15941/16102)   
Checking out files: 100% (2044/2044), done.nal/icingChecking out files:  21% (532/2445)   
Checking out files: 100% (333/333), done.
Checking out files: 100% (2714/2714), done.
Checking out files: 100% (326/326), done.
Checking out files: 100% (502/502), done.
Checking out files: 100% (2370/2370), done.
Checking out files: 100% (2123/2123), done.nal/iputilsChecking out files:  94% (1996/2123)   
Checking out files: 100% (2445/2445), done.nal/junit-paramsChecking out files:  78% (1908/2445)   
Checking out files: 100% (257/257), done.
Checking out files: 100% (1222/1222), done.
Checking out files: 100% (1264/1264), done.
Checking out files: 100% (1558/1558), done.
Checking out files: 100% (1265/1265), done.
Checking out files: 100% (4595/4595), done.
Checking out files: 100% (2423/2423), done.nal/linux-kselftestChecking out files:  10% (2327/21683)   
Checking out files: 100% (3241/3241), done.
Checking out files: 100% (1301/1301), done.
Checking out files: 100% (2362/2362), done.
Checking out files: 100% (2309/2309), done.
Checking out files: 100% (419/419), done.
Checking out files: 100% (3603/3603), done.
Checking out files: 100% (4664/4664), done.nal/libfuseChecking out files:  97% (4525/4664)   
Checking out files: 100% (7971/7971), done.nal/libgav1Checking out files:  83% (18204/21683)   
Checking out files: 100% (21683/21683), done.
Checking out files: 100% (2925/2925), done.
Checking out files: 100% (959/959), done.ernal/nullawayChecking out files:  85% (816/959)   
Checking out files: 100% (8748/8748), done.nal/plyChecking out files:  12% (536/4465)   
Checking out files: 100% (4465/4465), done.nal/python/rsaChecking out files:  99% (4464/4465)   
Checking out files: 100% (2627/2627), done.nal/rust/crates/async-stream-implChecking out files:  17% (447/2627)   
Checking out files: 100% (7979/7979), done.nal/rust/crates/crossbeam-utilsChecking out files:   6% (272/4463)   
Checking out files: 100% (4379/4379), done.
Checking out files: 100% (4463/4463), done.nal/rust/crates/downcast-rsChecking out files:  96% (4285/4463)   
Checking out files: 100% (60/60), done.xternal/rust/crates/ringChecking out files: 100% (60/60)   
Checking out files: 100% (89/89), done.xternal/rust/crates/rusticata-macrosChecking out files:  98% (88/89)   
Checking out files: 100% (8007/8007), done.nal/rust/crates/vsockChecking out files:  37% (2963/8007)   
Checking out files: 100% (3123/3123), done.
Checking out files: 100% (1561/1561), done.
Checking out files: 100% (8147/8147), done.
Checking out files: 100% (9463/9463), done.
Checking out files: 100% (971/971), done.
Checking out files: 100% (197/197), done.
Checking out files: 100% (692/692), done.
Checking out files: 100% (492/492), done.
Checking out files: 100% (1500/1500), done.
Checking out files: 100% (237/237), done.
Checking out files: 100% (28/28), done. 
Checking out files: 100% (122/122), done.
Checking out files: 100% (118/118), done.
Checking out files: 100% (4654/4654), done.are/google/graphics/commonChecking out files:  34% (8486/24514)   
Checking out files: 100% (8870/8870), done.
Checking out files: 100% (185/185), done.
Checking out files: 100% (14/14), done.  
Checking out files: 100% (24514/24514), done.
Checking out files: 100% (1548/1548), done.
Checking out files: 100% (48/48), done.ardware/qcom/data/ipacfg-mgrChecking out files:  97% (47/48)   
Checking out files: 100% (41/41), done.ardware/qcom/sdm845/displayChecking out files:  68% (28/41)   
Checking out files: 100% (14/14), done.
Checking out files: 100% (61/61), done.
Checking out files: 100% (7/7), done.
Checking out files: 100% (712/712), done.
Checking out files: 100% (53/53), done.
Checking out files: 100% (49/49), done.
Checking out files: 100% (50/50), done.
Checking out files: 100% (47/47), done.
Checking out files: 100% (40/40), done.
Checking out files: 100% (16/16), done.
Checking out files: 100% (1057/1057), done.
Checking out files: 100% (353/353), done.
Checking out files: 100% (7/7), done. 
Checking out files: 100% (19/19), done.
Checking out files: 100% (3146/3146), done.
Checking out files: 100% (6/6), done. external/volleyChecking out files:  13% (225/1644)   
Checking out files: 100% (1644/1644), done.
Checking out files: 100% (12/12), done.
Checking out files: 100% (7/7), done.
Checking out files: 100% (3602/3602), done.are/qcom/sdm845/thermalChecking out files:  99% (3566/3602)   
Checking out files: 100% (851/851), done.ilts/common-modules/virtual-device/4.19/x86-64Checking out files:  34% (291/851)   
Checking out files: 100% (685/685), done.
Checking out files: 100% (7883/7883), done.
Checking out files: 100% (999/999), done.
Checking out files: 100% (1576/1576), done.
Checking out files: 100% (6030/6030), done.
Checking out files: 100% (7276/7276), done.
Checking out files: 100% (1639/1639), done.
Checking out files: 100% (868/868), done.
Checking out files: 100% (534/534), done.
Checking out files: 100% (2044/2044), done.
Checking out files: 100% (3210/3210), done.
Checking out files: 100% (1495/1495), done.
Checking out files: 100% (1763/1763), done.ges/apps/CellBroadcastReceiverChecking out files:  58% (1023/1763)   
Checking out files: 100% (1816/1816), done.ts/common-modules/virtual-device/5.15/x86-64Checking out files:  97% (1762/1816)   
Checking out files: 100% (534/534), done.kages/apps/Car/RotaryControllerChecking out files:  70% (374/534)   
Checking out files: 100% (3254/3254), done.
Checking out files: 100% (200/200), done.
Checking out files: 100% (5632/5632), done.
Checking out files: 100% (2399/2399), done.
Checking out files: 100% (4809/4809), done.
Checking out files: 100% (496/496), done.
Checking out files: 100% (1363/1363), done.
Checking out files: 100% (1285/1285), done.
Checking out files: 100% (1867/1867), done.ges/modules/CellBroadcastServiceChecking out files:   0% (35/6526)   
Checking out files: 100% (567/567), done.
Checking out files: 100% (357/357), done.
Checking out files: 100% (42610/42610), done.
Checking out files: 100% (1288/1288), done.
Checking out files: 100% (276/276), done.
Checking out files: 100% (8464/8464), done.
Checking out files: 100% (324/324), done.
Checking out files: 100% (162/162), done.kages/providers/DownloadProviderChecking out files:  59% (96/162)   
Checking out files: 100% (375/375), done.
Checking out files: 100% (735/735), done.
Checking out files: 100% (159/159), done.ernal/xz-embeddedChecking out files: 100% (159/159)   
Checking out files: 100% (24/24), done.xternal/zopfliChecking out files:  58% (14/24)   
Checking out files: 100% (6526/6526), done.works/compile/slangChecking out files:  99% (6523/6526)   
Checking out files: 100% (107/107), done.meworks/libs/service_entitlementChecking out files:  65% (402/617)   
Checking out files: 100% (314/314), done.
Checking out files: 100% (197/197), done.
Checking out files: 100% (3232/3232), done.
Checking out files: 100% (617/617), done.
Checking out files: 100% (3584/3584), done.
Checking out files: 100% (3959/3959), done.
Checking out files: 100% (575/575), done.
Checking out files: 100% (446/446), done.
Checking out files: 100% (11977/11977), done.tools/syspropChecking out files:  82% (1467/1789)   
Checking out files: 100% (4160/4160), done.
Checking out files: 100% (17/17), done.
Checking out files: 100% (1789/1789), done.
Checking out files: 100% (410/410), done.
Checking out files: 100% (11975/11975), done.
Checking out files: 100% (364/364), done.
Checking out files: 100% (68/68), done. 
Checking out files: 100% (182/182), done.
Checking out files: 100% (175/175), done.
Checking out files: 100% (296/296), done.ols/doc_generationChecking out files:  29% (10402/34798)   
Checking out files: 100% (9218/9218), done.
Checking out files: 100% (1212/1212), done.
Checking out files: 100% (5960/5960), done.
Checking out files: 100% (22/22), done.packages/services/AlternativeNetworkAccessChecking out files:  81% (18/22)   
Checking out files: 100% (34798/34798), done.trebuchetChecking out files:   2% (248/9260)   
Checking out files: 100% (1523/1523), done.
Checking out files: 100% (1366/1366), done.
Checking out files: 100% (9260/9260), done.
Checking out files: 100% (683/683), done.
Checking out files: 100% (763/763), done.
Checking out files: 100% (172/172), done.
Checking out files: 100% (16294/16294), done.
Checking out files: 100% (8056/8056), done.
Checking out files: 100% (720/720), done.
Checking out files: 100% (8621/8621), done.
Checking out files: 100% (1904/1904), done.
Checking out files: 100% (2101/2101), done.
Checking out files: 100% (21254/21254), done.
Checking out files: 100% (18247/18247), done.
Checking out files: 100% (1667/1667), done.
Checking out files: 100% (18387/18387), done.lts/gradle-pluginChecking out files:  98% (18020/18387)   
Checking out files: 100% (1131/1131), done.uilts/module_sdk/artChecking out files:  18% (211/1131)   
Checking out: 100% (1134/1134), done in 28m46.180s
repo sync has finished successfully.
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ du -sh
136G    .
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 

编译部分

Checking out files: 100% (21254/21254), done.
Checking out files: 100% (18247/18247), done.
Checking out files: 100% (1667/1667), done.
Checking out files: 100% (18387/18387), done.lts/gradle-pluginChecking out files:  98% (18020/18387)   
Checking out files: 100% (1131/1131), done.uilts/module_sdk/artChecking out files:  18% (211/1131)   
Checking out: 100% (1134/1134), done in 28m46.180s
repo sync has finished successfully.
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ du -sh
136G    .
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ source build/envsetup.sh 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ lunch sdk_phone_x86_64


============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=13
TARGET_PRODUCT=sdk_phone_x86_64
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86_64
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-150-generic-x86_64-Ubuntu-18.04.6-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=TQ1A.230105.002.A1
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera hardware/google/camera/devices/EmulatedCamera device/generic/goldfish device/generic/yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ m
build/make/core/soong_config.mk:209: warning: BOARD_PLAT_PUBLIC_SEPOLICY_DIR has been deprecated. Use SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS instead.
build/make/core/soong_config.mk:210: warning: BOARD_PLAT_PRIVATE_SEPOLICY_DIR has been deprecated. Use SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS instead.
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=13
TARGET_PRODUCT=sdk_phone_x86_64
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86_64
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-150-generic-x86_64-Ubuntu-18.04.6-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=TQ1A.230105.002.A1
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera hardware/google/camera/devices/EmulatedCamera device/generic/goldfish device/generic/goldfish-opengl
============================================
[ 94% 376/397] link out/host/linux-x86/bin/go/soong-sdk/test/test
    0:28 test android/soong/cc
    0:13 test android/soong/aidl
    0:11 test android/soong/java
    0:10 test android/soong/apex
    0:10 test android/soong/rust
    0:03 compile out/host/linux-x86/bin/go/soong-sdk/test/android/soong/sdk.a


----------------------------------分割线, 编译成功后第二次编译--------------------------------


yzh@ubuntu:~/Desktop/aosp$ source build/envsetup.sh 
yzh@ubuntu:~/Desktop/aosp$ lunch sdk_phone_x86_64

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=13
TARGET_PRODUCT=sdk_phone_x86_64
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86_64
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-150-generic-x86_64-Ubuntu-18.04.6-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=TQ1A.230105.002.A1
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera hardware/google/camera/devices/EmulatedCamera device/generic/goldfish device/generic/goldfish-opengl
============================================
yzh@ubuntu:~/Desktop/aosp$ m
07:38:20 ************************************************************
07:38:20 You are building on a machine with 15.6GB of RAM
07:38:20 
07:38:20 The minimum required amount of free memory is around 16GB,
07:38:20 and even with that, some configurations may not work.
07:38:20 
07:38:20 If you run into segfaults or other errors, try reducing your
07:38:20 -j value.
07:38:20 ************************************************************
build/make/core/soong_config.mk:209: warning: BOARD_PLAT_PUBLIC_SEPOLICY_DIR has been deprecated. Use SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS instead.
build/make/core/soong_config.mk:210: warning: BOARD_PLAT_PRIVATE_SEPOLICY_DIR has been deprecated. Use SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS instead.
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=13
TARGET_PRODUCT=sdk_phone_x86_64
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86_64
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-150-generic-x86_64-Ubuntu-18.04.6-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=TQ1A.230105.002.A1
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera hardware/google/camera/devices/EmulatedCamera device/generic/goldfish device/generic/goldfish-opengl
============================================
[ 99% 456/458] compile out/host/linux-x86/bin/go/soong_build/obj/soong_build.a

#### build completed successfully (15:18 (mm:ss)) ####

yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ du -sh
243G    .
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ emulator 
INFO    | Android emulator version 31.3.9.0 (build_id 8748233) (CL:N/A)
INFO    | Storing crashdata in: /tmp/android-yzh/emu-crash.db, detection is enabled
INFO    | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
WARNING | Failed to open /home/yzh/.android/adbkey
WARNING | adbkey generation failed
ProbeKVM: This user doesn't have permissions to use KVM (/dev/kvm).
The KVM line in /etc/group is: [LINE_NOT_FOUND]

If the current user has KVM permissions,
the KVM line in /etc/group should end with ":" followed by your username.

If we see LINE_NOT_FOUND, the kvm group may need to be created along with permissions:
    sudo groupadd -r kvm
    # Then ensure /lib/udev/rules.d/50-udev-default.rules contains something like:
    # KERNEL=="kvm", GROUP="kvm", MODE="0660"
    # and then run:
    sudo gpasswd -a $USER kvm

If we see kvm:... but no username at the end, running the following command may allow KVM access:
    sudo gpasswd -a $USER kvm

You may need to log out and back in for changes to take effect.

ERROR   | x86_64 emulation currently requires hardware acceleration!
CPU acceleration status: This user doesn't have permissions to use KVM (/dev/kvm).
The KVM line in /etc/group is: [LINE_NOT_FOUND]

If the current user has KVM permissions,
the KVM line in /etc/group should end with ":" followed by your username.

If we see LINE_NOT_FOUND, the kv
More info on configuring VM acceleration on Linux:
https://developer.android.com/studio/run/emulator-acceleration#vm-linux
General information on acceleration: https://developer.android.com/studio/run/emulator-acceleration.
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ sudo chmod -R 777 /dev/kvm

[sudo] password for yzh: 
1Sorry, try again.
[sudo] password for yzh: 
yzh@ubuntu:~/Desktop/aosp$ 
yzh@ubuntu:~/Desktop/aosp$ emulator 
INFO    | Android emulator version 31.3.9.0 (build_id 8748233) (CL:N/A)
INFO    | Storing crashdata in: /tmp/android-yzh/emu-crash.db, detection is enabled
INFO    | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
WARNING | cannot add library /home/yzh/Desktop/aosp/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
INFO    | added library /home/yzh/Desktop/aosp/prebuilts/android-emulator/linux-x86_64/lib64/vulkan/libvulkan.so
ERROR   | Failed to create Vulkan instance.
WARNING | No adb private key exists
WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***
INFO    | Started GRPC server at 127.0.0.1:8554, security: Local, auth: none
INFO    | Advertising in: /run/user/1000/avd/running/pid_7254.ini
INFO    | Setting display: 0 configuration to: 1440x2960, dpi: 560x560 
WARNING | Failed to process .ini file /home/yzh/.android/emu-update-last-check.ini for reading.



相关文章

网友评论

      本文标题:编译Android系统源码

      本文链接:https://www.haomeiwen.com/subject/hdrmvdtx.html