Download msysgit and install
Download: http://code.google.com/p/msysgit/downloads/list,
Open git bash and execute the command
cd D:git clone https://android.googlesource.com/platform/manifest.git
Enter the command to switch to the manifest directory.
cd manifest
Git tag lists the branches of Android
git tag
Download the Android-2.2 system source code and enter the following command. If you want to download the source code of another version, you can download the version number listed in the checkout git tag.
git checkout android-2.2_r1
After checkout, the manifest/Default. xml file records the path of each module of android2.2.
Let's analyze the default. xml file,
Take bionic as an example. The path attribute indicates the relative path of bionic source code. Assume that the android source code is in D:/Android-source. After downloading bionic, it should be stored in the D:/Android-source/bionic directory.
The name attribute is the path of the bionic source code in the library. The complete path is http://android.googlesource.com/platform/bionic.git. if the source code is downloaded, you can download the bionic source code to the local directory by executing git clone.
<Project Path = "Bionic" name = "platform/bionic"/>
Android source code project a lot, one download is more troublesome, I wrote a Python script, double-click the download-src.py to execute this script, you can download the complete Android source code to the local.
PS: the premise for executing this script is that you have executed git checkout and selected the android source code version to download. If your manifest file is not D:/manifest/default. XML. Modify the script by yourself.
Download-src.py source code:
import xml.dom.minidomimport osfrom subprocess import call#downloaded source pathrootdir = "D:/android-source"#git program pathgit = "D:/Program Files/Git/bin/git.exe"dom = xml.dom.minidom.parse("D:/manifest/default.xml")root = dom.documentElementprefix = git + " clone https://android.googlesource.com/"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)