0. Pixel3 在Ubuntu22下Android12源码拉取 + 编译

0. Pixel3 在Ubuntu22下Android12源码拉取 + 编译

原文地址: http://www.androidcrack.com/index.php/archives/3/

1. 前言

这是一个非常悲伤的故事, 因为一个意外, 不小心把之前镜像的源码搞坏了. 也没做版本管理,恢复不了了. 那么只能说是重新做一次.

再者以前的镜像太老旧了, 所以我决定这次把镜像更新到Android 12, 它也是Pixel3所能支持的最高镜像了.

开篇之际, 同时会把所有非必要的镜像操作都作为博客, 记录出来. 供大家一起学习交流!

2. 源码拉取

Android 源代码位于由 Google 托管的一组 Git 仓库中。Git 仓库包含 Android 源代码的完整历史记录,其中包括对源代码的更改以及更改时间。

2.1 初始化客户端

首先我们需要创建一个工作目录

cd ~
mkdir android12
cd android12

2.2 代理配置及源码拉取

由于我们都是使用国内网络, 国外专线也十分之昂贵. 故而我们可以使用国内中科大源. 当然, 同时还希望大家自备梯子, 因为在其中,不缺乏有些东西需要访问Google. 所以我们在Ubuntu虚拟机上可以使用 proxychains4

sudo apt-get install proxychains4
vim /etc/proxychains4.conf

安装完成后, 我们需要对配置文件做一下配置,在配置文件的最末尾处编辑为如下

socks5 IP 端口

[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
socks5 192.168.100.152 7890

为了保证大家的环境一模一样. 建议想跟着此篇文章了解Android源码编译的读者, 都使用android-12.0.0-r1 版本的镜像. 方便更好的交流.

-b 选项用于标识您正在初始化的分支。如果 -b 未提供,则 repo init 默认采用主分支。如需查看分支和标记名称的列表,请参阅源代码标记和 build

-u 是必需选项,用于指定清单文件。清单是一个 XML 文件,用于指定 Android 源代码中的各种 Git 项目位于工作目录的什么位置。 在此示例中,清单文件的名称未指定,因此命令使用默认清单文件 (default.xml)。

proxychains4 repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-12.0.0_r1
proxychains4 repo sync -j8

然后我们就开始漫长的源码同步阶段了.

image-20240926101303783

当读者看到repo sync has finished successfully. 字样的时候,代码通常就下载成功了.

来自谷歌的"排查并解决同步问题"

https://source.android.com/docs/setup/download/troubleshoot-sync?hl=zh-cn

2.3 Repo客户端

2.3.1 repo清单格式

下方引用了一段来自谷歌官方的描述, 按照我的理解就是这个清单是一个配置git下载的列表文件, 它告诉repo应该去哪个仓库拉取代码.

A repo manifest describes the structure of a repo client; that is the directories that are visible and where they should be obtained from with git.

The basic structure of a manifest is a bare Git repository holding a single default.xml XML file in the top level directory.

Manifests are inherently version controlled, since they are kept within a Git repository. Updates to manifests are automatically obtained by clients during repo sync.

2.3.2清单 xml文件格式

进入到.repo文件夹中, 我们可以看到manifest.xml 这个是我们代码拉取的配置文件.

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT EDIT THIS FILE!  It is generated by repo and changes will be discarded.
If you want to use a different manifest, use `repo init -m <file>` instead.

If you want to customize your checkout by overriding manifest settings, use
the local_manifests/ directory instead.

For more information on repo manifests, check out:
https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
-->
<manifest>
  <include name="default.xml" />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值