Android源码仓库地址:https://android.googlesource.com/platform/manifest/+refs

  1. Git下载manifest描述文件
  1. git clone https://android.googlesource.com/platform/manifest

在这有许多问题,如连接失败,443问题等等。

这里推荐使用清华镜像来进行下载。

镜像使用帮助中指出, 将 https://android.googlesource.com/ 全部使用 https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/ 代替即可。这样下载就流畅多了。

  1. 查看分支
  1. 切换分支
  1. git checkout android-11.0.0_r45
  1. python脚本下载源代码
  1. import xml.dom.minidom
  2. import os
  3. from subprocess import call
  4. # downloaded source path
  5. rootdir = "D:/android_source_code/android-11.0.0_r45"
  6. # git program path
  7. git = "D:/Git/bin/git.exe"
  8. dom = xml.dom.minidom.parse("D:/android_source_code/manifest/default.xml")
  9. root = dom.documentElement
  10. prefix = git + " clone https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/"
  11. suffix = ".git"
  12. if __name__ == '__main__':
  13. if not os.path.exists(rootdir):
  14. os.mkdir(rootdir)
  15. for node in root.getElementsByTagName("project"):
  16. os.chdir(rootdir)
  17. d = node.getAttribute("path")
  18. last = d.rfind("/")
  19. if last != -1:
  20. d = rootdir + "/" + d[:last]
  21. if not os.path.exists(d):
  22. os.makedirs(d)
  23. os.chdir(d)
  24. cmd = prefix + node.getAttribute("name") + suffix
  25. call(cmd)

运行main函数即可开始下载。

在线查看网站