Ubuntu 虚拟机环境,编译AOSP源码

环境 : VMware虚拟机 Ubuntu 20.04.3 LTS

搭建配置开发环境

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 python

一。下载编译源码

1.下载repo工具

mkdir ~/bin

curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo

chmod +x ~/bin/repo

配置清华镜像地址

sudo apt install vim

vim .bashrc

编辑配置

export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

PATH=~/bin:$PATH

保存退出后,使配置生效

source ~/.bashrc

2.初始化仓库 同步远程代码

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

mkdir aosp

cd aosp 

初始化仓库,-b 指示分支,这里使用 android11

//其他版本查看地址

https://source.android.com/docs/setup/about/build-numbers?hl=zh-cn#source-code-tags-and-builds

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r48

报错:   

def print(self, *args, **kwargs):
            ^
SyntaxError: invalid syntax

原因:本机装了python2和python3,默认使用python2, 而repo需要python3

解决方法:

查看并删除本机python2

ll /usr/bin/python
lrwxrwxrwx 1 root root 16 Jul 28 15:16 /usr/bin/python -> /usr/bin/python2*

sudo rm /usr/bin/python

sudo ln -sf /usr/bin/python3 /usr/bin/python 

注意:repo工具需要python3 但是aosp源码编译可能需要python2。源码下载完成后,需要把本机python版本配置为python2,否则可能编译报错。

#同步远程代码

repo sync

下载 解压 6个小时左右

3.编译源码

如果repo拉代码修改过python版本,记得修改回python2版本。

source build/envsetup.sh
lunch aosp_x86_64-eng
make -j4

6核处理器 32G内存 编译了5个小时

二。源码运行

运行模拟器

emulator

报错:

1.CPU acceleration status: KVM requires a CPU that supports vmx or svm More info on configuring VM acceleration on Linux:

解决方法

虚拟化引擎设置 需要勾选上  虚拟化 Intel VT-x/EPT或 AMD-V/RVI(V)

2.emulator: ERROR: No AVD specified. Use '@foo' or '-avd foo' to launch a virtual device named 'foo'

解决方法:

重新配置要读取的模拟器信息

lunch aosp_x86_64-eng

启动模拟器

emulator

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2023-12-20 04:58:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-20 04:58:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-20 04:58:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-20 04:58:02       18 阅读

热门阅读

  1. Python基础dict字典定义与函数

    2023-12-20 04:58:02       38 阅读
  2. 【SpringBoot实战】基于MybatisPlus实现基本增删改查

    2023-12-20 04:58:02       51 阅读
  3. 【安全】audispd调研

    2023-12-20 04:58:02       37 阅读
  4. C#连接数据库40错误

    2023-12-20 04:58:02       38 阅读
  5. 64道Go机制高频题整理(附答案背诵版)

    2023-12-20 04:58:02       39 阅读
  6. 【周志华机器学习】学习笔记一:绪论

    2023-12-20 04:58:02       32 阅读
  7. Debian系统设置SSH密钥登陆

    2023-12-20 04:58:02       38 阅读
  8. 本地声明式缓存

    2023-12-20 04:58:02       35 阅读