来源:http://blog.csdn.net/droidpioneer/article/details/6612026
Android官方网站http://source.android.com/source/downloading.html对源代码的下载有详细的介绍,大家可以按照网站上介绍的方法一步步操作就可以了。
本文向大家介绍的是如何只对个别目录进行下载的方法,因为一方面由于网速的原因,很多时候完整下载所有的代码是办不到的,另一方面,我们可能只关心个别目录的源代码而已。
需要指出的是,Andrid的的源代码需要在Linux环境下下载的,在Windows环境下下载源代码的话大家可以安装Cygwin工具(PS:用Cygwin还可以在Windows下开发Android NDK 应用),配置好后下载方法是一样的。
好了,单个目录源码下载的具体步骤是:
第一步,按照官方网站的方法配置好git 和repo及相关的环境变量。
第二步,用 git clone方法对感兴趣的目录分别下载。
对于第二步,我们可以参考下面的例子。
源代码所在的地址是:http://android.git.kernel.org/
如果我们要对所有的Android源代码进行下载,下载命令是:
repo init -u git://android.git.kernel.org/platform/manifest.git
repo sync
当然,如果我们只想下载Android 2.3 gingerbread版的完整源代码,加上分支选项:
repo init -u git://android.git.kernel.org/platform/manifest.git –b gingerbread
repo sync
好了,如果只想下载单个目录的代码,参见下面的例子:
仅下载Launcher:
git clone git://android.git.kernel.org/platform/packages/apps/Launcher2.git
仅下载 Android 2.2 froyo版的Launcher:
git clone git://android.git.kernel.org/platform/packages/apps/Launcher2.git –b froyo
分别下载Android 2.2 froyo版的framework的各个目录:
git clone git://android.git.kernel.org/platform/frameworks/base.git -b froyo
git clone http://android.git.kernel.org/platform/frameworks/base.git -b froyo
git clone http://android.git.kernel.org/platform/frameworks/policies/base.git -b froyo
git clone http://android.git.kernel.org/platform/frameworks/ex.git -b froyo
git clone http://android.git.kernel.org/platform/frameworks/opt/com.google.android.git -b froyo
git clone http://android.git.kernel.org/platform/frameworks/opt/com.google.android.googlelogin.git -b froyo
git clone http://android.git.kernel.org/platform/frameworks/opt/emoji.git -b froyo
其他的例子就类推了,如果不清楚究竟哪些目录有git下载节点,可以直接通过浏览器访问http://android.git.kernel.org/网站了解Android源代码的分支结构:
1. git clone http://android.googlesource.com/kernel/common.git
2. git clone http://android.googlesource.com/kernel/experimental.git3. git clone http://android.googlesource.com/kernel/msm.git
4. git clone http://android.googlesource.com/kernel/omap.git
5. git clone http://android.googlesource.com/platform/bionic.git
6. git clone http://android.googlesource.com/platform/bootable/bootloader/legacy.git
7. git clone http://android.googlesource.com/platform/bootable/diskinstaller.git
8. git clone http://android.googlesource.com/platform/bootable/recovery.git
9. git clone http://android.googlesource.com/platform/bootloader/legacy.git
10. git clone http://android.googlesource.com/platform/build.git
11. git clone http://android.googlesource.com/platform/dalvik.git
12. git clone http://android.googlesource.com/platform/development.git
13. git clone http://android.googlesource.com/platform/external/aes.git
14. git clone http://android.googlesource.com/platform/external/alsa-lib.git
15. git clone http://android.googlesource.com/platform/external/alsa-utils.git
16. git clone http://android.googlesource.com/platform/external/apache-http.git
17. git clone http://android.googlesource.com/platform/external/astl.git
18. git clone http://android.googlesource.com/platform/external/bison.git
19. git clone http://android.googlesource.com/platform/external/bluez.git
20. git clone http://android.googlesource.com/platform/external/bsdiff.git
21. git clone http://android.googlesource.com/platform/external/bzip2.git
22. git clone http://android.googlesource.com/platform/external/clearsilver.git
23. git clone http://android.googlesource.com/platform/external/dbus.git
24. git clone http://android.googlesource.com/platform/external/dhcpcd.git
25. git clone http://android.googlesource.com/platform/external/dosfstools.git
26. git clone http://android.googlesource.com/platform/external/dropbear.git
27. git clone http://android.googlesource.com/platform/external/e2fsprogs.git
28. git clone http://android.googlesource.com/platform/external/eglib.git
29. git clone http://android.googlesource.com/platform/external/elfcopy.git
30. git clone http://android.googlesource.com/platform/external/elfutils.git
31. git clone http://android.googlesource.com/platform/external/embunit.git
32. git clone http://android.googlesource.com/platform/external/emma.git
33. git clone http://android.googlesource.com/platform/external/esd.git
34. git clone http://android.googlesource.com/platform/external/expat.git
35. git clone http://android.googlesource.com/platform/external/fdlibm.git
36. git clone http://android.googlesource.com/platform/external/freetype.git
37. git clone http://android.googlesource.com/platform/external/fsck_msdos.git
38. git clone http://android.googlesource.com/platform/external/gdata.git
39. git clone http://android.googlesource.com/platform/external/genext2fs.git
40. git clone http://android.googlesource.com/platform/external/giflib.git
41. git clone http://android.googlesource.com/platform/external/googleclient.git
42. git clone http://android.googlesource.com/platform/external/grub.git
43. git clone http://android.googlesource.com/platform/external/gtest.git
44. git clone http://android.googlesource.com/platform/external/hcidump.git
45. git clone http://android.googlesource.com/platform/external/icu4c.git
46. git clone http://android.googlesource.com/platform/external/iptables.git
47. git clone http://android.googlesource.com/platform/external/jdiff.git
48. git clone http://android.googlesource.com/platform/external/jhead.git
49. git clone http://android.googlesource.com/platform/external/jpeg.git
50. git clone http://android.googlesource.com/platform/external/junit.git
51. git clone http://android.googlesource.com/platform/external/lcc.git
52. git clone http://android.googlesource.com/platform/external/libffi.git
53. git clone http://android.googlesource.com/platform/external/libpcap.git
54. git clone http://android.googlesource.com/platform/external/libpng.git
55. git clone http://android.googlesource.com/platform/external/libxml2.git
56. git clone http://android.googlesource.com/platform/external/mtpd.git
57. git clone http://android.googlesource.com/platform/external/netcat.git
58. git clone http://android.googlesource.com/platform/external/netperf.git
59. git clone http://android.googlesource.com/platform/external/neven.git
60. git clone http://android.googlesource.com/platform/external/opencore.git
61. git clone http://android.googlesource.com/platform/external/openssl.git
62. git clone http://android.googlesource.com/platform/external/oprofile.git
63. git clone http://android.googlesource.com/platform/external/ping.git
64. git clone http://android.googlesource.com/platform/external/ppp.git
65. git clone http://android.googlesource.com/platform/external/protobuf.git
66. git clone http://android.googlesource.com/platform/external/qemu.git
67. git clone http://android.googlesource.com/platform/external/safe-iop.git
68. git clone http://android.googlesource.com/platform/external/skia.git
69. git clone http://android.googlesource.com/platform/external/sonivox.git
70. git clone http://android.googlesource.com/platform/external/sqlite.git
71. git clone http://android.googlesource.com/platform/external/srec.git
72. git clone http://android.googlesource.com/platform/external/strace.git
73. git clone http://android.googlesource.com/platform/external/tagsoup.git
74. git clone http://android.googlesource.com/platform/external/tcpdump.git
75. git clone http://android.googlesource.com/platform/external/tesseract.git
76. git clone http://android.googlesource.com/platform/external/tinyxml.git
77. git clone http://android.googlesource.com/platform/external/tremor.git
78. git clone http://android.googlesource.com/platform/external/webkit.git
79. git clone http://android.googlesource.com/platform/external/wpa_supplicant.git
80. git clone http://android.googlesource.com/platform/external/xdelta3.git
81. git clone http://android.googlesource.com/platform/external/yaffs2.git
82. git clone http://android.googlesource.com/platform/external/zlib.git
83. git clone http://android.googlesource.com/platform/frameworks/base.git
84. git clone http://android.googlesource.com/platform/frameworks/opt/com.google.android.git
85. git clone http://android.googlesource.com/platform/frameworks/opt/com.google.android.googlelogin.git
86. git clone http://android.googlesource.com/platform/frameworks/opt/emoji.git
87. git clone http://android.googlesource.com/platform/frameworks/policies/base.git
88. git clone http://android.googlesource.com/platform/hardware/alsa_sound.git
89. git clone http://android.googlesource.com/platform/hardware/libhardware.git
90. git clone http://android.googlesource.com/platform/hardware/libhardware_legacy.git
91. git clone http://android.googlesource.com/platform/hardware/msm7k.git
92. git clone http://android.googlesource.com/platform/hardware/ril.git
93. git clone http://android.googlesource.com/platform/manifest.git
94. git clone http://android.googlesource.com/platform/packages/apps/AlarmClock.git
95. git clone http://android.googlesource.com/platform/packages/apps/Browser.git
96. git clone http://android.googlesource.com/platform/packages/apps/Calculator.git
97. git clone http://android.googlesource.com/platform/packages/apps/Calendar.git
98. git clone http://android.googlesource.com/platform/packages/apps/Camera.git
99. git clone http://android.googlesource.com/platform/packages/apps/Contacts.git
100. git clone http://android.googlesource.com/platform/packages/apps/Email.git
101. git clone http://android.googlesource.com/platform/packages/apps/GoogleSearch.git
102. git clone http://android.googlesource.com/platform/packages/apps/HTMLViewer.git
103. git clone http://android.googlesource.com/platform/packages/apps/IM.git
104. git clone http://android.googlesource.com/platform/packages/apps/Launcher.git
105. git clone http://android.googlesource.com/platform/packages/apps/Mms.git
106. git clone http://android.googlesource.com/platform/packages/apps/Music.git
107. git clone http://android.googlesource.com/platform/packages/apps/OTAProvisioningClient.git
108. git clone http://android.googlesource.com/platform/packages/apps/PackageInstaller.git
109. git clone http://android.googlesource.com/platform/packages/apps/Phone.git
110. git clone http://android.googlesource.com/platform/packages/apps/Settings.git
111. git clone http://android.googlesource.com/platform/packages/apps/SoundRecorder.git
112. git clone http://android.googlesource.com/platform/packages/apps/Stk.git
113. git clone http://android.googlesource.com/platform/packages/apps/Sync.git
114. git clone http://android.googlesource.com/platform/packages/apps/Updater.git
115. git clone http://android.googlesource.com/platform/packages/apps/VoiceDialer.git
116. git clone http://android.googlesource.com/platform/packages/inputmethods/LatinIME.git
117. git clone http://android.googlesource.com/platform/packages/inputmethods/OpenWnn.git
118. git clone http://android.googlesource.com/platform/packages/inputmethods/PinyinIME.git
119. git clone http://android.googlesource.com/platform/packages/providers/ApplicationsProvider.git
120. git clone http://android.googlesource.com/platform/packages/providers/CalendarProvider.git
121. git clone http://android.googlesource.com/platform/packages/providers/ContactsProvider.git
122. git clone http://android.googlesource.com/platform/packages/providers/DownloadProvider.git
123. git clone http://android.googlesource.com/platform/packages/providers/DrmProvider.git
124. git clone http://android.googlesource.com/platform/packages/providers/GoogleContactsProvider.git
125. git clone http://android.googlesource.com/platform/packages/providers/GoogleSubscribedFeedsProvider.git
126. git clone http://android.googlesource.com/platform/packages/providers/ImProvider.git
127. git clone http://android.googlesource.com/platform/packages/providers/MediaProvider.git
128. git clone http://android.googlesource.com/platform/packages/providers/TelephonyProvider.git
129. git clone http://android.googlesource.com/platform/packages/providers/UserDictionaryProvider.git
130. git clone http://android.googlesource.com/platform/prebuilt.git
131. git clone http://android.googlesource.com/platform/recovery.git
132. git clone http://android.googlesource.com/platform/system/bluetooth.git
133. git clone http://android.googlesource.com/platform/system/core.git
134. git clone http://android.googlesource.com/platform/system/extras.git
135. git clone http://android.googlesource.com/platform/system/wlan/broadcom.git
136. git clone http://android.googlesource.com/platform/system/wlan/ti.git
137. git clone http://android.googlesource.com/platform/vendor/asus/eee_701.git
138. git clone http://android.googlesource.com/platform/vendor/csr/unifi-105x.git
139. git clone http://android.googlesource.com/platform/vendor/csr/unifi-60xx.git
140. git clone http://android.googlesource.com/platform/vendor/htc/dream-open.git
141. git clone http://android.googlesource.com/platform/vendor/qcom/surf.git
142. git clone http://android.googlesource.com/tools/android-issuetrackerredirect.git
143. git clone http://android.googlesource.com/tools/executablewar.git
144. git clone http://android.googlesource.com/tools/gerrit-contactstore.git
145. git clone http://android.googlesource.com/tools/gerrit-keyapplet.git
146. git clone http://android.googlesource.com/tools/gerrit.git
147. git clone http://android.googlesource.com/tools/gimd.git
148. git clone http://android.googlesource.com/tools/gwtexpui.git
149. git clone http://android.googlesource.com/tools/gwtjsonrpc.git
150. git clone http://android.googlesource.com/tools/gwtorm.git
151. git clone http://android.googlesource.com/tools/manifest.git
152. git clone http://android.googlesource.com/tools/protobuf.git
153. git clone http://android.googlesource.com/tools/repo.git
154. git clone http://android.googlesource.com/tools/test/manifest.git
155. git clone http://android.googlesource.com/tools/test/project0.git