Android源码仓库地址:https://android.googlesource.com/platform/manifest/+refs
- Git下载manifest描述文件
git clone https://android.googlesource.com/platform/manifest
在这有许多问题,如连接失败,443问题等等。
这里推荐使用清华镜像来进行下载。
镜像使用帮助中指出, 将
https://android.googlesource.com/全部使用https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/代替即可。这样下载就流畅多了。
- 查看分支
- 通过网站可以看到分支:https://android.googlesource.com/platform/manifest/+refs
- git命令查看:git tag
- 切换分支
git checkout android-11.0.0_r45
- python脚本下载源代码
import xml.dom.minidomimport osfrom subprocess import call# downloaded source pathrootdir = "D:/android_source_code/android-11.0.0_r45"# git program pathgit = "D:/Git/bin/git.exe"dom = xml.dom.minidom.parse("D:/android_source_code/manifest/default.xml")root = dom.documentElementprefix = git + " clone https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/"suffix = ".git"if __name__ == '__main__':if not os.path.exists(rootdir):os.mkdir(rootdir)for node in root.getElementsByTagName("project"):os.chdir(rootdir)d = node.getAttribute("path")last = d.rfind("/")if last != -1:d = rootdir + "/" + d[:last]if not os.path.exists(d):os.makedirs(d)os.chdir(d)cmd = prefix + node.getAttribute("name") + suffixcall(cmd)
运行main函数即可开始下载。
在线查看网站
- 可访问 https://cs.android.com 或 https://github.com/aosp-mirror 在线搜索及浏览 AOSP 源码。
- 直接去Android开发官网查看。官网更新比源码网站早些。
