1. Download tool
Download Msysgit, install the official download: http://www.git-scm.com/download/
Download python, install official website: http://www.python.org
2.cd/d
mkdir Android
CD Android
git clone git://mirrors.ustc.edu.cn/aosp/platform/manifest
3. CD Manifest
git tag (list the Android version number)
git checkout android-5.1.1_r18 (checkout you want to download the version number, after checkout, Manifest/default.xml file is recorded in the android5.1 system the path of each module)
4. Create the download-src.py file, and note that the path is changed
Import Xml.dom.minidom
Import OS
From subprocess Import call
#downloaded Source Path
RootDir = "D:/android-source"
#git Program Path
git = "D:/program files/git/bin/git.exe"
Dom = Xml.dom.minidom.parse ("D:/manifest/default.xml")
root = Dom.documentelement
prefix = git + "Clone git://mirrors.ustc.edu.cn/aosp/"
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)
5. Execute the Script
Android Source code Download method