关闭

如何在windows下下载android源码

9569人阅读 评论(15) 收藏 举报

 进入不了source.android.com,故是网友介绍的一种方式下载的。

下载完毕后,源码目前有3.83G大小。

 

首先,你先到 http://code.google.com/p/msysgit/downloads/list 上下载Git-xxx.exe,我下載的是 Git-1.6.2.2-preview20090408.exe

 

下載下來後,直接按確定到底,就可以完成安裝。裝完後,執行他的 Git Bash 程式。你會看到像是下面這樣的命令列視窗。其實,這就是個和 Linux 上相同的 bash,不少 Linux 命令都有,連 Perl 也找的到。不過,最重要的是,他整合進 git 這個命令。

git窗口

 

接著,用 cd 命令,進入到你要下載 Android 原始碼的目錄後,再執行 git clone <repository> 命令,就可以下載你指定的 package。

舉個例子來說,我想要下載 Browsers 這個應用程式的原始碼。底下是我在 Git Bash 中下的命令。

cd /d/AndroidProgram/AndroidSource/1.0r1/Android_open_source/platform/packages/apps
git clone git://android.git.kernel.org/platform/packages/apps/Browser.git

這步的關鍵就在,你要知道你所要下載原始碼的 repository。告訴你,所有的 Android repositories 都在 http://git.source.android.com。進入這個網站後,你會看到下面這樣的畫面。

andorid git列表

Project 這一欄列的就是 Android 中每個 sub-project 的路徑。前面再加上 git://android.git.kernel.org/ 就是他的 repository 路徑。

再舉個例子來說,如果你像要下載 SQLite 的原始碼,那就下:

git clone git://android.git.kernel.org/platform/external/sqlite.git

如果你只是想看某個檔案的內容,你也可以點最右邊的 tree 連結,就這樣一路點下去,看到檔案列表時,再點最右邊的 raw 連結。看到沒,原始碼就顯示在你的瀏覽器上。

 

如果你想下载全部源代码怎么办,目前没有看到好的办法,我的做法是将上面的git列表中的内容拷贝下来,然后写成一个shell命令执行。

 

我的做法:

 

1:拷贝git列表时,请点击http://android.git.kernel.org/右下角的"TXT"按钮,此时将出现TXT文档的git列表,将每列后面的"Android+Open+Source+Project"替换为空,然后在每列前面加上git clone git://android.git.kernel.org/即可,建议选择一个可以进行列操作的编辑器,比如说ultredit.我1min不到就将列表搞定了。

注意需要进入到相应的目录下才能下载。我下载完毕后发现全部放到根目录下了,故最后用下面的python脚本进行了移动

import fileinput
import sys
import re
import os
import string

outfp = open("D:/cj/project/android/tools/move.sh","w")
for line in fileinput.input("D:/cj/project/android/tools/git-list"):
    path = os.path.dirname(line)
    file = os.path.basename(line)
    file = file.replace("/r", "")
    file = file.replace("/n", "")
    xx = ""
    for dirx in path.split("/"):
        xx = xx + dirx + "/"
        outfp.write("mkdir " + xx + "/n")
    outfp.write("mv " + file + " " + path + "/n")
outfp.close()


 

2:将该列表保存在源代码目录下,文件名为update.sh

 

3:在git窗口下执行: update.sh

 

然后你就慢慢等待吧。

 

git列表文件为:

git clone git://android.git.kernel.org/tools/gwtexpui.git
git clone git://android.git.kernel.org/tools/gerrit-contactstore.git
git clone git://android.git.kernel.org/tools/gerrit-keyapplet.git
git clone git://android.git.kernel.org/tools/executablewar.git
git clone git://android.git.kernel.org/tools/test/project0.git
git clone git://android.git.kernel.org/tools/test/manifest.git
git clone git://android.git.kernel.org/tools/repo.git
git clone git://android.git.kernel.org/tools/protobuf.git
git clone git://android.git.kernel.org/tools/manifest.git
git clone git://android.git.kernel.org/tools/gwtorm.git
git clone git://android.git.kernel.org/tools/gwtjsonrpc.git
git clone git://android.git.kernel.org/tools/gerrit.git
git clone git://android.git.kernel.org/tools/android-issuetrackerredirect.git
git clone git://android.git.kernel.org/platform/vendor/qcom/surf.git
git clone git://android.git.kernel.org/platform/vendor/htc/dream.git
git clone git://android.git.kernel.org/platform/vendor/asus/eee_701.git
git clone git://android.git.kernel.org/platform/system/wlan/broadcom.git
git clone git://android.git.kernel.org/platform/system/wlan/ti.git
git clone git://android.git.kernel.org/platform/system/extras.git
git clone git://android.git.kernel.org/platform/system/core.git
git clone git://android.git.kernel.org/platform/system/bluetooth.git
git clone git://android.git.kernel.org/platform/recovery.git
git clone git://android.git.kernel.org/platform/prebuilt.git
git clone git://android.git.kernel.org/platform/packages/inputmethods/PinyinIME.git
git clone git://android.git.kernel.org/platform/packages/inputmethods/LatinIME.git
git clone git://android.git.kernel.org/platform/packages/providers/UserDictionaryProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/TelephonyProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/MediaProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/ImProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/GoogleSubscribedFeedsProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/GoogleContactsProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/DrmProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/DownloadProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/ContactsProvider.git
git clone git://android.git.kernel.org/platform/packages/providers/CalendarProvider.git


git clone git://android.git.kernel.org/platform/packages/apps/OTAProvisioningClient.git
git clone git://android.git.kernel.org/platform/packages/apps/VoiceDialer.git
git clone git://android.git.kernel.org/platform/packages/apps/Updater.git
git clone git://android.git.kernel.org/platform/packages/apps/Sync.git
git clone git://android.git.kernel.org/platform/packages/apps/Stk.git
git clone git://android.git.kernel.org/platform/packages/apps/SoundRecorder.git
git clone git://android.git.kernel.org/platform/packages/apps/Settings.git
git clone git://android.git.kernel.org/platform/packages/apps/Phone.git
git clone git://android.git.kernel.org/platform/packages/apps/PackageInstaller.git
git clone git://android.git.kernel.org/platform/packages/apps/Music.git
git clone git://android.git.kernel.org/platform/packages/apps/Mms.git
git clone git://android.git.kernel.org/platform/packages/apps/Launcher.git
git clone git://android.git.kernel.org/platform/packages/apps/IM.git
git clone git://android.git.kernel.org/platform/packages/apps/HTMLViewer.git
git clone git://android.git.kernel.org/platform/packages/apps/GoogleSearch.git
git clone git://android.git.kernel.org/platform/packages/apps/Email.git
git clone git://android.git.kernel.org/platform/packages/apps/Contacts.git
git clone git://android.git.kernel.org/platform/packages/apps/Camera.git
git clone git://android.git.kernel.org/platform/packages/apps/Calendar.git
git clone git://android.git.kernel.org/platform/packages/apps/Calculator.git
git clone git://android.git.kernel.org/platform/packages/apps/Browser.git
git clone git://android.git.kernel.org/platform/packages/apps/AlarmClock.git
git clone git://android.git.kernel.org/platform/manifest.git
git clone git://android.git.kernel.org/platform/hardware/libhardware_legacy.git
git clone git://android.git.kernel.org/platform/hardware/ril.git
git clone git://android.git.kernel.org/platform/hardware/msm7k.git
git clone git://android.git.kernel.org/platform/hardware/libhardware.git
git clone git://android.git.kernel.org/platform/hardware/alsa_sound.git
git clone git://android.git.kernel.org/platform/frameworks/policies/base.git
git clone git://android.git.kernel.org/platform/frameworks/opt/emoji.git
git clone git://android.git.kernel.org/platform/frameworks/opt/com.google.android.googlelogin.git
git clone git://android.git.kernel.org/platform/frameworks/opt/com.google.android.git
git clone git://android.git.kernel.org/platform/frameworks/base.git
git clone git://android.git.kernel.org/platform/external/alsa-utils.git
git clone git://android.git.kernel.org/platform/external/dosfstools.git
git clone git://android.git.kernel.org/platform/external/zlib.git
git clone git://android.git.kernel.org/platform/external/yaffs2.git
git clone git://android.git.kernel.org/platform/external/xdelta3.git
git clone git://android.git.kernel.org/platform/external/wpa_supplicant.git
git clone git://android.git.kernel.org/platform/external/webkit.git
git clone git://android.git.kernel.org/platform/external/tremor.git
git clone git://android.git.kernel.org/platform/external/tinyxml.git
git clone git://android.git.kernel.org/platform/external/tesseract.git
git clone git://android.git.kernel.org/platform/external/tcpdump.git
git clone git://android.git.kernel.org/platform/external/tagsoup.git
git clone git://android.git.kernel.org/platform/external/strace.git
git clone git://android.git.kernel.org/platform/external/srec.git
git clone git://android.git.kernel.org/platform/external/sqlite.git
git clone git://android.git.kernel.org/platform/external/sonivox.git
git clone git://android.git.kernel.org/platform/external/skia.git
git clone git://android.git.kernel.org/platform/external/safe-iop.git
git clone git://android.git.kernel.org/platform/external/qemu.git
git clone git://android.git.kernel.org/platform/external/protobuf.git
git clone git://android.git.kernel.org/platform/external/ppp.git
git clone git://android.git.kernel.org/platform/external/ping.git
git clone git://android.git.kernel.org/platform/external/oprofile.git
git clone git://android.git.kernel.org/platform/external/openssl.git
git clone git://android.git.kernel.org/platform/external/opencore.git
git clone git://android.git.kernel.org/platform/external/neven.git
git clone git://android.git.kernel.org/platform/external/netperf.git
git clone git://android.git.kernel.org/platform/external/netcat.git
git clone git://android.git.kernel.org/platform/external/libxml2.git
git clone git://android.git.kernel.org/platform/external/libpng.git
git clone git://android.git.kernel.org/platform/external/libpcap.git
git clone git://android.git.kernel.org/platform/external/libffi.git
git clone git://android.git.kernel.org/platform/external/jpeg.git
git clone git://android.git.kernel.org/platform/external/jhead.git
git clone git://android.git.kernel.org/platform/external/jdiff.git
git clone git://android.git.kernel.org/platform/external/iptables.git
git clone git://android.git.kernel.org/platform/external/icu4c.git
git clone git://android.git.kernel.org/platform/external/grub.git
git clone git://android.git.kernel.org/platform/external/googleclient.git
git clone git://android.git.kernel.org/platform/external/giflib.git
git clone git://android.git.kernel.org/platform/external/genext2fs.git
git clone git://android.git.kernel.org/platform/external/gdata.git
git clone git://android.git.kernel.org/platform/external/fsck_msdos.git
git clone git://android.git.kernel.org/platform/external/freetype.git
git clone git://android.git.kernel.org/platform/external/fdlibm.git
git clone git://android.git.kernel.org/platform/external/expat.git
git clone git://android.git.kernel.org/platform/external/esd.git
git clone git://android.git.kernel.org/platform/external/emma.git
git clone git://android.git.kernel.org/platform/external/embunit.git
git clone git://android.git.kernel.org/platform/external/elfutils.git
git clone git://android.git.kernel.org/platform/external/elfcopy.git
git clone git://android.git.kernel.org/platform/external/e2fsprogs.git
git clone git://android.git.kernel.org/platform/external/dropbear.git
git clone git://android.git.kernel.org/platform/external/dhcpcd.git
git clone git://android.git.kernel.org/platform/external/dbus.git
git clone git://android.git.kernel.org/platform/external/clearsilver.git
git clone git://android.git.kernel.org/platform/external/bzip2.git
git clone git://android.git.kernel.org/platform/external/bsdiff.git
git clone git://android.git.kernel.org/platform/external/bluez.git
git clone git://android.git.kernel.org/platform/external/bison.git
git clone git://android.git.kernel.org/platform/external/apache-http.git
git clone git://android.git.kernel.org/platform/external/alsa-lib.git
git clone git://android.git.kernel.org/platform/external/aes.git
git clone git://android.git.kernel.org/platform/development.git
git clone git://android.git.kernel.org/platform/dalvik.git
git clone git://android.git.kernel.org/platform/build.git
git clone git://android.git.kernel.org/platform/bootloader/legacy.git
git clone git://android.git.kernel.org/platform/bootable/recovery.git
git clone git://android.git.kernel.org/platform/bootable/diskinstaller.git
git clone git://android.git.kernel.org/platform/bootable/bootloader/legacy.git
git clone git://android.git.kernel.org/platform/bionic.git
git clone git://android.git.kernel.org/kernel/experimental.git
git clone git://android.git.kernel.org/kernel/msm.git
git clone git://android.git.kernel.org/kernel/common.git
 

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:445827次
    • 积分:5636
    • 等级:
    • 排名:第5723名
    • 原创:98篇
    • 转载:18篇
    • 译文:0篇
    • 评论:118条
    文章分类
    最新评论