版权声明:本文为博主原创文章,未经博主同意不得转载。 https://blog.csdn.net/maosidiaoxian/article/details/36625727
今天在下载andriod源代码,特来与大家分享一下我的经验。
当然,网上教下载源代码的教程较多,本文主要针对在GFW下下载源代码出现的各种问题的解决方法。
1、首先安装下载clientgit , curl。
命令例如以下:
sudo apt-get install curl git
2、创建一个bin文件夹,加入到PATH当中。
mkdir ~/binPATH=~/bin:$PATH
3、下载repo的脚本并加入可运行权限。
curl http://git-repo.googlecode.com/files/repo-1.13 > ~/bin/repochmod a+x ~/bin/repo在这里。问题就出来了。
自5月底開始,谷歌的相关网站,基本上都已经不能直接訪问了,当然,我一直用goagentFQ,所受影响不大。除了打不开tools.android.com这个网站之外。
在这里。我假设你已经有代理工具的了(假设没有,会折腾的用goagent,不会折腾的一个月花几块钱买一个)。
以下我们就须要设置curl的代理,方法非常easy。加个參数 -x 代理地址。
比方我的代理server为我在局域网里的还有一部电脑。IP为192.168.137.1,端口为8087.那么上面下载 repo脚本的命令就应该为:
curl -x 192.168.137.1:8087 http://git-repo.googlecode.com/files/repo-1.13 > ~/bin/repo
下载之后,再改动权限,如上面所看到的。
4、创建源代码文件夹并进入。
mkdir android4.4.2cd android4.4.2
5、初始化repo。
repo init -u https://android.googlesource.com/platform/manifest -b android-cts-4.2_r2在-b后面跟着的是分支名。不出意外,这里问题又来了。googlesource.com网站被墙。所以这里不能直接下载,须要设置代码。这里设置代码非常easy,设置一下https.proxy的变量就能够了。
例如以下:
https_proxy=192.168.137.1:8087
后面相应的值记得改回你自己的代理server地址及端口。
(补述,http的代理也要设置 。后面下载代码会用到,方法同上。设置一下http_proxy变量。
)
然后我们再运行初始化。这时。问题又来了。控制台输出:
Get https://code.google.com/p/git-repo/error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://code.google.com/p/git-repo/info/refsfatal: HTTP request failed显示是证书问题。导入证书我不知道怎么整,只是我找到了还有一种方法,就是取消GIT的SSL验证。命令例如以下:
export GIT_SSL_NO_VERIFY=1然后我们再运行初始化,这时成功了(假设网络断开请多试一试)。
6、下载源代码。
最后,运行repo sync就可以。
7、关于获取源代码清单
以下说一下怎样获取各个版本号的分支名。
首先。没有设置代理的要先设置GIT的代理,例如以下:
export https_proxy=192.168.137.1:8087export https_proxy=192.168.137.1:8087export GIT_SSL_NO_VERIFY=1当中第一、二行各自是设置http及https的代理server。后面的值改动为你自己的取代server的地址。
第三行是取消SSL验证,不然会出现SSL验证问题。
然后运行以下命令克隆该git 仓库。
git clone https://android.googlesource.com/platform/manifest接着运行git branch -a,就可以得到各分支名,例如以下:
msdx@msdx-ubuntu:~/code/A/manifest$ git branch -a* master remotes/origin/HEAD -> origin/master remotes/origin/android-1.6_r1 remotes/origin/android-1.6_r1.1 remotes/origin/android-1.6_r1.2 remotes/origin/android-1.6_r1.3 remotes/origin/android-1.6_r1.4 remotes/origin/android-1.6_r1.5 remotes/origin/android-1.6_r2 remotes/origin/android-2.0.1_r1 remotes/origin/android-2.0_r1 remotes/origin/android-2.1_r1 remotes/origin/android-2.1_r2 remotes/origin/android-2.1_r2.1p remotes/origin/android-2.1_r2.1p2 remotes/origin/android-2.1_r2.1s remotes/origin/android-2.2.1_r1 remotes/origin/android-2.2.1_r2 remotes/origin/android-2.2.2_r1 remotes/origin/android-2.2.3_r1 remotes/origin/android-2.2.3_r2 remotes/origin/android-2.2.3_r2.1 remotes/origin/android-2.2_r1 remotes/origin/android-2.2_r1.1 remotes/origin/android-2.2_r1.2 remotes/origin/android-2.2_r1.3 remotes/origin/android-2.3.1_r1 remotes/origin/android-2.3.2_r1 remotes/origin/android-2.3.3_r1 remotes/origin/android-2.3.3_r1.1 remotes/origin/android-2.3.4_r0.9 remotes/origin/android-2.3.4_r1 remotes/origin/android-2.3.5_r1 remotes/origin/android-2.3.6_r0.9 remotes/origin/android-2.3.6_r1 remotes/origin/android-2.3.7_r1 remotes/origin/android-2.3_r1 remotes/origin/android-4.0.1_r1 remotes/origin/android-4.0.1_r1.1 remotes/origin/android-4.0.1_r1.2 remotes/origin/android-4.0.2_r1 remotes/origin/android-4.0.3_r1 remotes/origin/android-4.0.3_r1.1 remotes/origin/android-4.0.4_r1 remotes/origin/android-4.0.4_r1.1 remotes/origin/android-4.0.4_r1.2 remotes/origin/android-4.0.4_r2 remotes/origin/android-4.0.4_r2.1 remotes/origin/android-4.1.1_r1 remotes/origin/android-4.1.1_r1.1 remotes/origin/android-4.1.1_r2 remotes/origin/android-4.1.1_r3 remotes/origin/android-4.1.1_r4 remotes/origin/android-4.1.1_r5 remotes/origin/android-4.1.1_r6 remotes/origin/android-4.1.1_r6.1 remotes/origin/android-4.1.2_r1 remotes/origin/android-4.1.2_r2 remotes/origin/android-4.1.2_r2.1 remotes/origin/android-4.2.1_r1 remotes/origin/android-4.2.1_r1.1 remotes/origin/android-4.2.1_r1.2 remotes/origin/android-4.2.2_r1 remotes/origin/android-4.2.2_r1.1 remotes/origin/android-4.2.2_r1.2 remotes/origin/android-4.2.2_r1.2b remotes/origin/android-4.2_r1 remotes/origin/android-4.3.1_r1 remotes/origin/android-4.3_r0.9 remotes/origin/android-4.3_r0.9.1 remotes/origin/android-4.3_r1 remotes/origin/android-4.3_r1.1 remotes/origin/android-4.3_r2 remotes/origin/android-4.3_r2.1 remotes/origin/android-4.3_r2.2 remotes/origin/android-4.3_r2.2-cts remotes/origin/android-4.3_r2.3 remotes/origin/android-4.3_r3 remotes/origin/android-4.3_r3.1 remotes/origin/android-4.4.1_r1 remotes/origin/android-4.4.2_r1 remotes/origin/android-4.4.2_r2 remotes/origin/android-4.4.3_r1 remotes/origin/android-4.4.3_r1.1 remotes/origin/android-4.4.4_r1 remotes/origin/android-4.4_r1 remotes/origin/android-4.4_r1.1 remotes/origin/android-4.4_r1.2 remotes/origin/android-cts-2.2_r8 remotes/origin/android-cts-2.3_r10 remotes/origin/android-cts-2.3_r11 remotes/origin/android-cts-2.3_r12 remotes/origin/android-cts-4.0.3_r1 remotes/origin/android-cts-4.0.3_r2 remotes/origin/android-cts-4.0_r1 remotes/origin/android-cts-4.1_r1 remotes/origin/android-cts-4.1_r2 remotes/origin/android-cts-4.1_r4 remotes/origin/android-cts-4.2_r2 remotes/origin/android-cts-verifier-4.0.3_r1 remotes/origin/android-cts-verifier-4.0_r1 remotes/origin/android-sdk-4.0.3-tools_r1 remotes/origin/android-sdk-4.0.3_r1 remotes/origin/android-sdk-4.4.2_r1 remotes/origin/android-sdk-adt_r16.0.1 remotes/origin/android-sdk-adt_r20 remotes/origin/android-sdk-support_r11 remotes/origin/chromium-dev remotes/origin/froyo remotes/origin/gingerbread remotes/origin/gingerbread-release remotes/origin/ics-mr0 remotes/origin/ics-mr1 remotes/origin/ics-plus-aosp remotes/origin/idea133 remotes/origin/idea133-weekly-release remotes/origin/jb-dev remotes/origin/jb-mr1-dev remotes/origin/jb-mr1-dev-plus-aosp remotes/origin/jb-mr1.1-dev remotes/origin/jb-mr1.1-dev-plus-aosp remotes/origin/jb-mr2-dev remotes/origin/jumper-stable remotes/origin/kitkat-cts-dev remotes/origin/kitkat-dev remotes/origin/l-preview remotes/origin/master remotes/origin/master-art remotes/origin/master-art-host remotes/origin/master-dalvik remotes/origin/master-dalvik-host remotes/origin/tools-canary-release remotes/origin/tools_ndk_r9d remotes/origin/tools_r20 remotes/origin/tools_r21 remotes/origin/tools_r21.1 remotes/origin/tools_r22 remotes/origin/tools_r22.2 remotes/origin/tools_r22.6 remotes/origin/tradefed remotes/origin/ub-tools-idea133 remotes/origin/ub-tools-idea133-milestone remotes/origin/ub-tools-idea133-release remotes/origin/ub-tools-master
最后。附上我已经下载好的源代码:。
我下载的东西,事实上有51G左右,当中.repo占了约42G。下载源代码请留够硬盘