Download the latest Android source code from github and githubandroid source code

Source: Internet
Author: User

Download the latest Android source code from github and githubandroid source code

Since the end of May this year, Google was completely attacked by the wall and all Google websites were inaccessible. This time, it included android.org, googlesource.com, and code.google.com. Android official resources cannot be accessed. It is of course difficult to download Android code.

This article explains how to download the latest andoridsource code from github.com/andorid. As the saying goes, "It is better to authorize fish to fish." This article not only provides a link to the packaged source code, but also shows how I downloaded it, I hope this will help you with similar problems.


Github.com/androidoverview

Open github.com/androidand you can see:

The link of each project is listed in the middle. Manage (a git-based command line tool developed by Google) manages all projects. Therefore, if you only want to download the source code of a project, you can download it separately (for example, you can download the platform_frameworks_base project if you want to develop an App and check the source code of the SDK ).


How to download the code of a project?

If you have used git, you can use the following command to obtain the code of the remote Repository:

Git clone [repository URL]
The repository URL is displayed on the right bar of the github project page, for example (text box below clone URL ):


Of course, to configure the "App source code debugging" environment, click the "Download ZIP" button to Download the source code package in the zip format, and select the downloaded source code package during Eclipse debugging.


How to batch download the Android source code on github

Here is the focus of this article-download the android source code on github in batches.

Based on the process of downloading a project separately, you can download the source code of all projects in two ways:

The following question is how to get such a URL?

Of course, it is from the webpage (that is, the HTML file of the page )!

Now the question is how to get these webpages?

The method I came up with was to use CURL.

Ps: CURL is a command line upload and download tool that supports multiple protocols, including HTTP, HTTPS, and FTP.

If you do not have curl, you can use the following command to download it:

sudo apt-get install curl

With CURL used to capture pages, you will not be able to get the repository URL or ZIP package URL:

Capture shards first.


Capture page

In:

https://github.com/android?page=N
Where N represents the "page number", such as the second page, is the https://github.com/android? Page = 2

Therefore, the bash script can be used to easily write the code for capturing the five pages (you can directly execute the following command in the terminal ):

for ((i=1; i<=5; i++)); docurl https://github.com/android?page=$i > android.github.com.$i.html;done

There are shortcuts

You can see the home page URL and repository URL of the project:

Repository URL = homepage URL +. git

For example, the homepage URL of platform_frameworks_base is:

https://github.com/android/platform_frameworks_base
The repository URL is:

https://github.com/android/platform_frameworks_base.git
Of course, if you have a github.com account and the pubkey of the current environment has been added to the profile, you can also use the ssh protocol to download (instead of https). The ssh download URL is:

git://github.com/android/platform_frameworks_base.git
It can be seen that obtaining the repository URL does not require further grabbing the project homepage (the following section only describes how to obtain all repository URLs ).

Resolution Page

Now the question is-how to get the repository URL from these pages.

You can quickly find the HTML code block corresponding to the link on the page through the "Review element" menu of the browser, such:


The <a href = "xxx"> hyperlink of the platform_frameworks_base project is surrounded by a

According to the two rules just found:

You can write the python code (getGitRepos. py) that parses the homepage (repository URL) of each project ):

#! /Usr/bin/pythonimport sysflag = Falselink_prefix = 'https: // github.com '# Change https to gitallLines = sys. stdin. readlines () for curLine in allLines: if curLine. find ('repo-list-name')> = 0: flag = Trueif flag: pos = curLine. find ('href = "') if pos> = 0: pos + = len ('href ="') last = curLine [pos:] end = last. find ('"') link = last [: end] # name to path. name = link [link. rfind ('/') + 1:] prefix = name. find ('Platform _ ') if prefix> = 0: name = name [len ('Platform _'):] # ignore platform_path = name. replace ('_', '/') link = link_prefix + link # print 'curl', link, '>', name # https://github.com/android/platform_external_qemu.gitprint 'git clone ', link + '. git ', path # output git clone command flag = False
The reason for parsing in python is that python is concise and can be used in other languages.

This python program reads and parses the text from the standard input. In actual use, the redirection operator can be used to replace the standard input with the previous github.com/androidchild pages.

The path parameter of the git clone command output by the program ignores the platform _ prefix before the repository name, which makes the source code structure that is finally downloaded similar to that of repo sync.


You can first test it on a page to see if the parsed URL is correct (the above python code is changed correctly). Enter the following command on the terminal:

./getGitRepos.py < android.github.com.1.html
The command output is:
git clone https://github.com/android/platform_dalvik.git dalvikgit clone https://github.com/android/platform_bionic.git bionicgit clone https://github.com/android/platform_system_core.git system/coregit clone https://github.com/android/kernel_common.git kernel/commongit clone https://github.com/android/platform_external_qemu.git external/qemugit clone https://github.com/android/platform_build.git buildgit clone https://github.com/android/platform_development.git developmentgit clone https://github.com/android/platform_frameworks_base.git frameworks/basegit clone https://github.com/android/platform_manifest.git manifestgit clone https://github.com/android/platform_frameworks_support.git frameworks/supportgit clone https://github.com/android/platform_packages_apps_settings.git packages/apps/settingsgit clone https://github.com/android/platform_external_dhcpcd.git external/dhcpcdgit clone https://github.com/android/platform_external_webkit.git external/webkitgit clone https://github.com/android/platform_external_protobuf.git external/protobufgit clone https://github.com/android/platform_packages_providers_mediaprovider.git packages/providers/mediaprovidergit clone https://github.com/android/platform_external_elfutils.git external/elfutilsgit clone https://github.com/android/platform_external_strace.git external/stracegit clone https://github.com/android/platform_hardware_libhardware.git hardware/libhardwaregit clone https://github.com/android/platform_external_tinyxml.git external/tinyxmlgit clone https://github.com/android/platform_external_oprofile.git external/oprofile

The test basically encountered a problem, because getGitRepos. py outputs the git clone command and can execute the actual download action after execution; therefore, you need to save the output;

Run the following command to save the git clone command parsed on each subpage to a text file:

for page in `ls android.github.com.*`; doecho parse $page./getGitRepos.py < $page >> gitRepos.txt;done

With gitrepos.txt, which is full of git clonecommand, you can run the following command:

sh gitRepos.txt

One-click Download

To facilitate the use of the majority of users, I have written the following cloneRepos. sh:

#!/bin/bash# clone AOSP each repo from https://github.com/android# this shell depends on git, curl and python 2.# INSTALL depends:#sudo apt-get install git curl python## by xu(xusiwei1236@163.com).# download github AOSP sub pagesfor ((i=1; i<=5; i++)); doecho get AOSP subpage https://github.com/android?page=$icurl https://github.com/android?page=$i > android.github.com.$i.html;done# parse git repo URL from each sub pagesmkdir reposcat /dev/null > gitRepos.txtfor page in `ls android.github.com.*`; doecho parse $page./getGitRepos.py < $page >> gitRepos.txt;done# clone repossh gitRepos.txt
In addition, I have packed cloneRepos. sh and getGitRepos. py together. You can download and use them at http://download.csdn.net/detail/xusiwei1236/7960925.

Of course, if you are confused, you can directly copy the generated gitrepos.txt and paste it into the terminal to download all the Android source code:

git clone https://github.com/android/platform_dalvik.git dalvikgit clone https://github.com/android/platform_bionic.git bionicgit clone https://github.com/android/platform_system_core.git system/coregit clone https://github.com/android/kernel_common.git kernel/commongit clone https://github.com/android/platform_external_qemu.git external/qemugit clone https://github.com/android/platform_build.git buildgit clone https://github.com/android/platform_development.git developmentgit clone https://github.com/android/platform_frameworks_base.git frameworks/basegit clone https://github.com/android/platform_manifest.git manifestgit clone https://github.com/android/platform_frameworks_support.git frameworks/supportgit clone https://github.com/android/platform_packages_apps_settings.git packages/apps/settingsgit clone https://github.com/android/platform_external_dhcpcd.git external/dhcpcdgit clone https://github.com/android/platform_external_webkit.git external/webkitgit clone https://github.com/android/platform_external_protobuf.git external/protobufgit clone https://github.com/android/platform_packages_providers_mediaprovider.git packages/providers/mediaprovidergit clone https://github.com/android/platform_external_elfutils.git external/elfutilsgit clone https://github.com/android/platform_external_strace.git external/stracegit clone https://github.com/android/platform_hardware_libhardware.git hardware/libhardwaregit clone https://github.com/android/platform_external_tinyxml.git external/tinyxmlgit clone https://github.com/android/platform_external_oprofile.git external/oprofilegit clone https://github.com/android/platform_external_neven.git external/nevengit clone https://github.com/android/platform_external_netperf.git external/netperfgit clone https://github.com/android/platform_external_netcat.git external/netcatgit clone https://github.com/android/platform_external_libxml2.git external/libxml2git clone https://github.com/android/platform_external_libpng.git external/libpnggit clone https://github.com/android/platform_external_libpcap.git external/libpcapgit clone https://github.com/android/platform_external_libffi.git external/libffigit clone https://github.com/android/platform_external_jpeg.git external/jpeggit clone https://github.com/android/platform_external_jhead.git external/jheadgit clone https://github.com/android/platform_external_jdiff.git external/jdiffgit clone https://github.com/android/platform_external_iptables.git external/iptablesgit clone https://github.com/android/platform_external_icu4c.git external/icu4cgit clone https://github.com/android/platform_external_giflib.git external/giflibgit clone https://github.com/android/platform_external_freetype.git external/freetypegit clone https://github.com/android/platform_external_fdlibm.git external/fdlibmgit clone https://github.com/android/platform_external_expat.git external/expatgit clone https://github.com/android/platform_external_esd.git external/esdgit clone https://github.com/android/platform_external_emma.git external/emmagit clone https://github.com/android/platform_external_dropbear.git external/dropbeargit clone https://github.com/android/platform_external_apache-http.git external/apache-httpgit clone https://github.com/android/platform_external_openssl.git external/opensslgit clone https://github.com/android/platform_external_sonivox.git external/sonivoxgit clone https://github.com/android/platform_packages_providers_telephonyprovider.git packages/providers/telephonyprovidergit clone https://github.com/android/platform_packages_providers_downloadprovider.git packages/providers/downloadprovidergit clone https://github.com/android/platform_packages_providers_contactsprovider.git packages/providers/contactsprovidergit clone https://github.com/android/platform_packages_providers_calendarprovider.git packages/providers/calendarprovidergit clone https://github.com/android/platform_packages_apps_voicedialer.git packages/apps/voicedialergit clone https://github.com/android/platform_packages_apps_stk.git packages/apps/stkgit clone https://github.com/android/platform_packages_apps_soundrecorder.git packages/apps/soundrecordergit clone https://github.com/android/platform_packages_apps_phone.git packages/apps/phonegit clone https://github.com/android/platform_packages_apps_packageinstaller.git packages/apps/packageinstallergit clone https://github.com/android/platform_packages_apps_music.git packages/apps/musicgit clone https://github.com/android/platform_packages_apps_mms.git packages/apps/mmsgit clone https://github.com/android/platform_packages_apps_htmlviewer.git packages/apps/htmlviewergit clone https://github.com/android/platform_packages_apps_email.git packages/apps/emailgit clone https://github.com/android/platform_packages_apps_contacts.git packages/apps/contactsgit clone https://github.com/android/platform_packages_apps_camera.git packages/apps/cameragit clone https://github.com/android/platform_packages_apps_calendar.git packages/apps/calendargit clone https://github.com/android/platform_packages_apps_calculator.git packages/apps/calculatorgit clone https://github.com/android/platform_packages_apps_browser.git packages/apps/browsergit clone https://github.com/android/platform_hardware_ril.git hardware/rilgit clone https://github.com/android/platform_external_zlib.git external/zlibgit clone https://github.com/android/platform_external_yaffs2.git external/yaffs2git clone https://github.com/android/platform_external_tcpdump.git external/tcpdumpgit clone https://github.com/android/platform_external_tagsoup.git external/tagsoupgit clone https://github.com/android/platform_external_srec.git external/srecgit clone https://github.com/android/platform_external_sqlite.git external/sqlitegit clone https://github.com/android/platform_external_skia.git external/skiagit clone https://github.com/android/platform_external_safe-iop.git external/safe-iopgit clone https://github.com/android/platform_external_ppp.git external/pppgit clone https://github.com/android/kernel_msm.git kernel/msmgit clone https://github.com/android/platform_system_bluetooth.git system/bluetoothgit clone https://github.com/android/platform_prebuilt.git prebuiltgit clone https://github.com/android/platform_packages_providers_drmprovider.git packages/providers/drmprovidergit clone https://github.com/android/platform_external_ping.git external/pinggit clone https://github.com/android/platform_external_dbus.git external/dbusgit clone https://github.com/android/tools_repo.git tools/repogit clone https://github.com/android/android.github.io.git android.github.iogit clone https://github.com/android/platform_external_wpa_supplicant.git external/wpa/supplicantgit clone https://github.com/android/platform_packages_apps_googlesearch.git packages/apps/googlesearchgit clone https://github.com/android/platform_system_wlan_ti.git system/wlan/tigit clone https://github.com/android/platform_packages_providers_googlecontactsprovider.git packages/providers/googlecontactsprovidergit clone https://github.com/android/platform_packages_apps_im.git packages/apps/imgit clone https://github.com/android/platform_packages_providers_improvider.git packages/providers/improvidergit clone https://github.com/android/platform_external_tremor.git external/tremorgit clone https://github.com/android/platform_packages_apps_sync.git packages/apps/syncgit clone https://github.com/android/platform_packages_apps_alarmclock.git packages/apps/alarmclockgit clone https://github.com/android/platform_external_aes.git external/aesgit clone https://github.com/android/platform_external_clearsilver.git external/clearsilvergit clone https://github.com/android/platform_external_googleclient.git external/googleclientgit clone https://github.com/android/platform_packages_apps_launcher.git packages/apps/launchergit clone https://github.com/android/platform_external_bluez.git external/bluezgit clone https://github.com/android/platform_external_gdata.git external/gdatagit clone https://github.com/android/platform_frameworks_opt_com.google.android.git frameworks/opt/com.google.androidgit clone https://github.com/android/platform_external_elfcopy.git external/elfcopygit clone https://github.com/android/platform_frameworks_policies_base.git frameworks/policies/basegit clone https://github.com/android/platform_packages_apps_updater.git packages/apps/updatergit clone https://github.com/android/platform_external_opencore.git external/opencore


Android: Who has the specific download method of the latest Google Code and how to obtain the source Code path from the website

This is an official website description of source.android.com/source/downloading.html
Since the kernel. git fails, it is just like this.
You can consider using
Github.com/android

How can I add an open-source project downloaded from github for android development to my own project?

We recommend that you first understand the usage of the android library, instead of simply copying the jar file to the libs file.

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.