Download Android source code on Windows (sorted out) and android source code

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.