下载安装git
1.git安装参考:
2. 查看git安装目录:
//在cmd中输入以下命令:
where git
下载安装python
1.软件下载地址:
2.软件安装参考
下载Android源码
1.创建源码的存放地址
D:\project
2.把存放目录作为本地的git仓库,进入project文件夹,在git bash中执行以下命令
git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git
3.执行完后本地文件夹会生成新文件

4.选择要下载的版本
git tag //列举出所有的版本
git checkout android-10.0.0_r6 //切换到android-10.0.0_r6这个版本上
5.下载Android源码需要用到python脚本
#test.py【脚本名称随意】
import xml.dom.minidom
import os
from subprocess import call
#downloaded source path
rootdir = "D:/project"
#git program path
git = "C:/Program Files/Git/bin/git.exe"
dom = xml.dom.minidom.parse("D:/project/manifest/default.xml")
root = dom.documentElement
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)
6.在cmd中执行python脚本
python test.py
7.国内Android源码镜像
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
http://mirrors.ustc.edu.cn/aosp/
网友评论