Download Android source code on Windows (sorted out) and android source code
Google officially downloads the source code from Ubuntu, but now we need to download the Android source code file from Windows.
The website address is: https://android.googlesource.com/
It contains the source code of each part of the Android system. You only need to download platform.
Click to enter.
Address: https://android.googlesource.com/platform/manifest
1. Preparations
Download. The source code is downloaded using the Python script. Therefore, you need to install a python environment.
2. Download the XML description file
Enter a folder to store the XML description file. Open Git Bash and execute the following command:
git clone https://android.googlesource.com/platform/manifest
Not surprisingly, the download will be completed soon, if there is an interruption, please use the scientific approach to the Internet to download again, here we recommend a stew hosts: http://levi.yii.so/archives/3553
After the download is complete, run the following command:
git tag
Select the version you want to download, and then execute the following command to check out the corresponding version information, here has android-5.1.1_r8 as an example:
git checkout android-5.1.1_r8
The path of the android source code is defined in the default. xml file.
3. Compile a python script to download the source code.
The content of the file is as follows and then explained in detail:
import xml.dom.minidomimport osfrom subprocess import call#downloaded source pathrootdir = "D:/Android/source/android-5.1.1_r8"#git program pathgit = "C:/Program Files (x86)/Git/bin/git.exe"dom = xml.dom.minidom.parse("D:/Android/source/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)
Row 3: rootdir indicates the source code storage path.
Row 3: git indicates the installation path of git.
Row 11th: Download the detected default. xml file path
If the path is different, modify it according to your own situation.
The last step is to execute this python script for download...
python download-src.py