Framework -- 下载Android系统源码

源代码控制工具  |  Android 开源项目  |  Android Open Source Project

所需工具

1、Repo
Windows安装repo的真正解决方案_针叶的博客-CSDN博客_repo windows

sudo apt-get install repo

2、git

3、python3

sudo apt-get install  python-is-python3

前置工作

设置目录区分大小写

针对WSL,这个必须设置,否则会预编译失败
[[Android 源码编译#You are building on a case-insensitive filesystem.]]

如果是wsl,还需要修改下安装目录
Windows10子系统WSL修改默认安装目录到其他盘_zhang-ge的博客-CSDN博客

月代码包方式下载

因为下载源代码对于服务器也是一种巨大的消耗,清华源给出了月同步代码包来减少压力,通过下载提供的月代码包,然后同步的方式减少下载压力

解压后,再执行repo sync

repo下载

建议使用linux子系统,否则会出现一些问题

以下命令必须要再git-bash 中执行

安装 Repo 步骤类似,只不过所有都替换成谷歌官方的:

mkdir ~/bin
PATH=~/bin:$PATH
#curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
curl -sSL 'https://gerrit-googlesource.proxy.ustclug.org/git-repo/+/master/repo?format=TEXT' |base64 -d > ~/bin/repo
chmod a+rx ~/bin/repo

然后注意,先下载最新的 repo 工具源码,再进行 init 操作:
使用--depth 1-c 参数后,能快速增加下载速度,极大减少空间占用,但是使用了--depth就不能checkout

# --depth 1 git 深度为1,表示不下载历史commit
repo init --depth 1 -u git://mirrors.ustc.edu.cn/aosp/platform/manifest
# 执行下载,-c: 仅下载当前分支 -j4: 4线程下载
repo sync -c -j4

如需签出 master 分支,请运行以下命令:

repo init -u https://android.googlesource.com/platform/manifest -b master

如需签出 master 之外的其他分支,请使用 -b 指定此分支。 如需查看分支列表,请参阅源代码标记和 build

代码源

中科大的源:
使用这个,速度快
AOSP 镜像使用帮助 — USTC Mirror Help 文档

git://mirrors.ustc.edu.cn/aosp/platform/manifest

清华的源:

https://gerrit-google.tuna.tsinghua.edu.cn/git-repo

常见问题

error: .repo/manifests/: contains uncommitted changes

原因:
repo sync error: .repo/manifests/: contains uncommitted changes - GoneWithWind - 博客园 (cnblogs.com)
老外的 git status or git diff 没有变化,可我在 .repo/manifests 执行git status 有变化`

解决:
进入.repo/manifests 目录,然后执行 git config core.filemode false, 问题解决了。

作者

AriaLyy

发布于

2022-11-12

许可协议

CC BY-NC-SA 4.0

评论