windows下载Android系统源码

1.安装 git

官网:https://git-scm.com/downloads/

2.安装 Python

官网:https://www.python.org/downloads/

3.下载源码

    1.下载manifest.git

        方法一:git clone https://android.googlesource.com/platform/manifest.git(需要梯子)

        方法二:git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git(清华源,不需要梯子)

    2.checkout分支

        git checkout 分支号 (分支号:切换到刚下载的manifest目录下,git bash使用git branch -a显示所有分支)

        切换成功后会显示:You are in 'detached HEAD' state. You can look around, make experimental......

    3.使用 Python 执行脚本进行源代码下载

        1.创建文件 python_download.py,将下面代码复制进去 ,记得修改代码中路径

          import xml.dom.minidom

          import os

          from subprocess import call

          # 1. 修改为源码要保存的路径---必须修改

          rootdir = "E:\AndroidSource_11.0.0_r9"

          # 2. 设置 git 安装的路径---必须修改

          git = "D:\Git\cmd\git.exe"

          # 3. 修改为第一步中 manifest 中 default.xml 保存的路径---必须修改

          dom = xml.dom.minidom.parse("D:\Repo\manifest\default.xml")

          root = dom.documentElement

          #prefix = git + " clone https://android.googlesource.com/"

          # 4. 没有梯子就使用清华源下载

          prefix = git + " clone https://aosp.tuna.tsinghua.edu.cn/"

          suffix = ".git" 

          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") + suffix 

              call(cmd)

        4.执行 Python 脚本下载

          右键python文件 -> 打开方式 ->python (不推荐使用开始菜单用python打开py文件,会疯狂弹出cmd窗口。而这种就只会在一个窗口中下载)

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容