Windows 环境下载 Android 源码
前言
Android 官网(该方式不适合 Windows 平台):https://source.android.com/source/downloading.html
可是我就想在 Windows 中使用 Source Insight 看看源代码,当然可以!
准备环境
- 安装 git
- 安装 Python
- 自备梯子
- 硬盘剩余容量最好大于 100G
1. 安装 git
官网:https://git-scm.com/downloads/
图形化工具:https://tortoisegit.org/
什么?不会安装 git,那还看什么源码!自行百度!
2. 安装 Python
官网:https://www.python.org/downloads/
安装参考:http://jingyan.baidu.com/article/c910274be14d64cd361d2dd8.html
只需要安装好运行环境即可
3. 自备梯子
没有梯子?那就使用清华源:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
下载源码
1. 打开 Git Bash,用 git 克隆源代码仓库
1 | git clone https://android.googlesource.com/platform/manifest.git |
这时 D:/android_source_code/ 目录下会出现一个 manifest 目录,进入此目录,里面除了 git 的配置目录外,clone 下来了一个 default.xml 文件。
2. 切换到想要的源码版本分支
去这里 https://source.android.com/source/build-numbers.html#source-code-tags-and-builds
找到想要的版本分支,并复制。
1 | cd manifest |
3. 使用 Python 执行脚本进行源代码下载
将下面的代码复制,创建文件 python_download.py,并保存。
1 | import xml.dom.minidom |
4. 执行 Python 脚本开始下载
打开 Python 客户端
打开上一步保存的 python_download.py 脚本文件
点击 Run->Run Module 来运行脚本,或直接按F5运行。
静静地等待下载完成吧。