下载android4.4.2源码全过程(附已下载的源码)

今天在下载andriod源码,特来与大家分享一下我的经验。当然,网上教下载源码的教程较多,本文主要针对在GFW下下载源码出现的各种问题的解决方法。

1、首先安装下载客户端git , curl。

命令如下:

sudo apt-get install curl git

2、创建一个bin目录,加入到PATH当中。

mkdir ~/bin
PATH=~/bin:$PATH

3、下载repo的脚本并添加可执行权限。

curl http://git-repo.googlecode.com/files/repo-1.13 > ~/bin/repo
chmod a+x ~/bin/repo

在这里,问题就出来了。自5月底开始,谷歌的相关网站,基本上都已经不能直接访问了,当然,我一直用*FQ,所受影响不大,除了打不开tools.android.com这个站点之外。在这里,我假设你已经有代理工具的了(如果没有,会折腾的用*,不会折腾的一个月花几块钱买一个)。下面我们就需要设置curl的代理,方法很简单,加个参数 -x 代理地址。比如我的代理服务器为我在局域网里的另一部电脑,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.2
cd android4.4.2

5、初始化repo。

repo init -u https://android.googlesource.com/platform/manifest -b android-cts-4.2_r2

在-b后面跟着的是分支名。不出意外,这里问题又来了。googlesource.com站点被墙,所以这里不能直接下载,需要设置代码。这里设置代码很简单,设置一下https.proxy的变量就可以了。如下:

https_proxy=192.168.137.1:8087

后面对应的值记得改回你自己的代理服务器地址及端口。

(补述,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/refs
fatal: HTTP request failed

显示是证书问题。导入证书我不知道怎么整,不过我找到了另一种方法,就是取消GIT的SSL验证。命令如下:

export GIT_SSL_NO_VERIFY=1

然后我们再执行初始化,这时成功了(如果网络断开请多试一试)。

6、下载源码。

最后,执行repo sync即可。

7、关于获取源码清单

下面说一下如何获取各个版本的分支名。

首先,没有设置代理的要先设置GIT的代理,如下:

export https_proxy=192.168.137.1:8087
export https_proxy=192.168.137.1:8087
export GIT_SSL_NO_VERIFY=1

其中第一、二行分别是设置http及https的代理服务器,后面的值修改为你自己的代替服务器的地址。

第三行是取消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

最后,附上我已经下载好的源码:http://zdz.la/KN8Nai

我下载的东西,其实有51G左右,其中.repo占了约42G,下载源码请留够硬盘

上一篇:真的,关于深度学习与计算机视觉,看这一篇就够了 | 硬创公开课


下一篇:基于sysbench-0.5的MySQL自动化压测及分析出图