首页 > 其他分享 >AOSP下载且编译

AOSP下载且编译

时间:2023-05-14 18:57:34浏览次数:39  
标签:git cn 编译 dev repo AOSP 下载

一、简介

AOSP:Android Open Source Project

二、环境要求

我们可以先了解官网(https://source.android.com/docs/setup/start/requirements?hl=zh-cn)的对设备的要求的介绍:

2.1、软硬件要求

image
我们可以看到官网对硬件的要求是磁盘最少250GB的可用磁盘空间,内存最少需要 16GB,如何内存不够16GB,这里可以通过交换空间(就是用磁盘空间当内存用,可参考:AOSP源码编译-交换空间)

2.2、搭建构建环境

image
通过官网介绍可以了解到,构建环境最好是linux系统,而MacOS不在支持了,但是也是可以的。
因此,我们可以在window上安装虚拟机+Ubuntu的形式(VMware的配置可以参考:虚拟机的选择与使用),但是自己正好有一台配置比较低主机直接装的Ubuntu20.04.1 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

3.1、镜像地址

AOSP官方地址:
https://source.android.com/docs/setup/build/downloading?hl=zh-cn
中科大镜像:
https://mirrors.ustc.edu.cn/help/aosp.html
清华镜像:
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP

3.2、 下载 repo 工具

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

repo的运行过程中会尝试访问官方的 git 源更新自己,如果想使用 tuna 的镜像源进行更新,可以将如下内容复制到你的 ~/.bashrc 或者 ~/.zshrc 里。

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

3.3、 初始化仓库并同步远程代码

git config --global user.email "[email protected]"
git config --global user.name "Your Name"
mkdir aosp
cd asop
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest
repo sync # 会自动下载 当前最新源码

下载指定版本源码

#初始化仓库,-b 指示分支,这里使用 android10
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r41
#同步远程代码
repo sync

-b 后面的值参考源代码标记和 build。这里选用了 android-10.0.0_r41 版本用于学习。Android 每年都会更新一个大版本,学习的角度来说,选择一个不太老的版本即可,不必追新。
10.0.0_r41

3.4、 编译源码

可以参考官网的编译Android

3.4.1 source build

source build/envsetup.sh

3.4.2 lunch

lunch

选择要编译的AOSP版本
image

简要说明编译的类型:
1.user:限制所有权限,用于发布给用户使用的最终版本。
2.userdebug: 开放部分权限,允许root。
3.eng:工程师模式,开放所有权限并且有额外的调试工具。
如果只是编译出一个正常的AOSP环境,直接选择26
输出提示告诉我们也可以直接使用名称选择版本:lunch aosp_x86_64-eng, 这种方式是一步到位

3.4.3 make

输入m,会根据当前CPU的能力,自动控制性能来编译
输入make -j4,开启多线程4来编译【由于我的电脑处理器数量是2,所以可以用标准的 4 就可以了

make -j4

编译过程很长:

3.4.4 运行模拟器

emulator 

image

标签:git,cn,编译,dev,repo,AOSP,下载
From: https://www.cnblogs.com/zuojie/p/17399781.html

相关文章