Download Android source code for Windows

Source: Internet
Author: User

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)

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.