【Android 源码】Android源码下载指南

文章目录

前言

这是关于Android源码下载的过程记录。

环境:Windows上通过VMware安装的Ubuntu系统

安装Repo

创建Repo文件目录

复制代码
mkdir ~/bin
PATH=~/bin:$PATH

下载Repo工具,给权限

复制代码
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

初始化Repo

创建目录存放源码。

复制代码
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY

配置的Git用户和邮件

复制代码
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

选择分支

代号、标记和细分版本号 | Android 开源项目 | Android Open Source Project (google.cn)

选择自己需要下载的源码分支。

到这里,由于需要梯子,会出现访问拒绝。国内可以使用其他源。

没有梯子

替换为清华源

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

用下面命令初始化仓库并指定分支,此处以android-8.0.0_r17分支为例。

复制代码
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-8.0.0_r17

有梯子

运行 repo init 以获取最新版本的 Repo 及其最近的所有错误更正内容。您必须为清单指定一个网址,该网址用于指定 Android 源代码中包含的各个代码库将位于工作目录中的什么位置。

复制代码
repo init -u https://android.googlesource.com/platform/manifest

初始化成功后,系统将显示一条消息,告诉您 Repo 已在工作目录中完成初始化。客户端目录中现在应包含一个 .repo 目录,清单等文件将保存在该目录下。

下载源码

复制代码
repo sync

为了提速,可以通过参数配置,可以参考下面的配置:

复制代码
repo sync -c -j8

整个命令 repo sync -c -j8 的意思是使用 repo 工具同步 Android 项目的源代码,同时忽略历史记录并使用 8 个并行线程进行同步。

下载开始

看到下面的状态,表示下载开始。

参考

下载源代码 | Android 开源项目 | Android Open Source Project (google.cn)

相关推荐
我是好小孩2 小时前
【Android】布局优化:include、merge、ViewStub以及Inflate()源码浅析
android
GISer_Jing2 小时前
2025年Flutter与React Native对比
android·flutter·react native
MasterLi80233 小时前
我的读书清单
android·linux·学习
怪兽20143 小时前
fastjson在kotlin不使用kotlin-reflect库怎么使用?
android·开发语言·kotlin
彭同学学习日志3 小时前
Kotlin Fragment 按钮跳转报错解决:Unresolved reference ‘floatingActionButton‘
android·开发语言·kotlin
Gracker4 小时前
Android Perfetto 系列 9 - CPU 信息解读
android
Gracker4 小时前
Android Perfetto 系列 8:深入理解 Vsync 机制与性能分析
android
Gracker5 小时前
Android Perfetto 系列 07 - MainThread 和 RenderThread 解读
android
Gracker5 小时前
Android Perfetto 系列 5:Android App 基于 Choreographer 的渲染流程
android
Gracker5 小时前
Android Perfetto 系列 6:为什么是 120Hz?高刷新率的优势与挑战
android