Ubuntu 13.04下载Android 4.0.1源码过程

Linux大全评论566 views阅读模式

Ubuntu 13.04下载Android4.0.1源码过程最初我参考的是 http://www.linuxidc.com/Linux/2011-06/37782.htm

进行下载安装的,但弄着弄着就发现不太对劲了。这里记录下详细过程:

1,我的前提是已经搭建好了Android开发环境,也即jdk已经安装好了,输入java -version来检查是否成功。搭建android开发环境可以看【http://www.linuxidc.com/Linux/2013-07/87018.htm】 和 【http://www.linuxidc.com/Linux/2013-07/87020.htm】.

相关阅读:

如何在32位Ubuntu 11.10 下编译Android 4.0.1源码和goldfish内核 http://www.linuxidc.com/Linux/2011-12/49775.htm

2,首先要安装git工具,而repo是基于git的。同时要安装所需的若干软件,命令如下:

sudo apt-get install git-core flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl valgrind

最后的valgrind是为了编译时用,一次安完了省事。如果是为了下载源码,只需安装curl和git-core就足够了。curl是一个利用URL语法在命令行方式下工作的文件 传输工具,它支持很多协议,包括FTP、FTPS、HTTP、HTTPS、TELENT等,我们需要安装它从网络 上获取Repo脚本文件。然后curl就用不到了。repo是基于git的,git是一个分布式版本控制软件。由于android源码是由很多个部分组成的,如果用git的话需要多次git clone。为此google提供了repo,其实质就是若干个git命令写的脚本。这是curl  git repo三者之间的关系。关于repo和git的使用,可以参考这里:

(1),http://www.linuxidc.com/Linux/2013-07/87021.htm

(2),http://www.linuxidc.com/Linux/2013-07/87022.htm

3,利用curl下载repo脚本

在普通用户下登录,不是root。这时~表示/home/xxx/的目录,在~下新建一个bin文件夹,用来放下载的repo脚本。参考android的官方指导文档http://source.android.com/source/downloading.html ,然后将~/bin目录添加到PATH。方法为sudo gedit /etc/profile, 然后添加 PATH=$PATH:~/bin    保存关闭后,再终端输入 source /etc/profile使设置生效。事实上这里也可以用绝对路径来写死,/home/xxx/bin 需要注意的是,这一切都是在普通用户下,如果以root用户登录,~表示的是/root文件夹。所以此次下载android源码一律是普通用户,不要随便切换。因为里面的~在普通用户和root用户下表示的地方不一样。如果用绝对路径写死则无此问题。

然后终端输入:

curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo用这条命令下载repo脚本到刚建的bin文件夹。

老罗的博客里的命令是:wget https://dl-ssl.google.com/dl/googlesource/git-repo/repo 用的是wget,应该也可以。我用的是上面的curl命令。然后chmod a+x ~/bin/repo为其增加可执行权限。

4,新建一个文件夹,即是repo的工作空间,将源码下载到此处。我新建的目录是/home/administrator/document/androidSource.  cd到这个目录下,要确保这个目录一般用户可以访问读写。

然后就要用repo init命令来初始化repo了,如果输入:

repo init -u https://android.googlesource.com/platform/manifest则是让repo下载最新的android源码。一般我们可以通过-b参数指定下载的android版本,输入:

repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1则是让repo下载4.0.1的源码,也可以用-b Jelly Bean来指定android的版本,具体可以参考:http://source.android.com/source/initializing.html

和 http://source.android.com/source/build-numbers.html,尤其是第二个链接来选定版本号比较好。

如果输入上面的repo init  .................xxx,再进入下一步骤虽然可以下载源码,但是下载中间会出现如下报错:

error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/manifest/info/refs 
fatal: HTTP request failed 
error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/manifest/info/refs 
fatal: HTTP request failed 
Fetching projects:  9% (20/221)  error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/external/bison/info/refs 
fatal: HTTP request failed 
Fetching projects:  10% (23/221)  error: Failed to connect to 2404:6800:4008:c01::52: Network is unreachable while accessing https://android.googlesource.com/platform/external/apache-xml/info/refs 
fatal: HTTP request failed 
error: Failed to connect to 2404:6800:4008:c01::52: Network is unreachable while accessing https://android.googlesource.com/platform/external/astl/info/refs 
fatal: HTTP request failed 
error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/external/bluetooth/glib/info/refs 
fatal: HTTP request failed 
error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/external/astl/info/refs 
fatal: HTTP request failed 
Fetching projects:  11% (25/221)  error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/external/apache-xml/info/refs 

错误的核心就是 error android.googlesource.com/platform/manifest/info/refs,参考这里 http://www.linuxidc.com/Linux/2013-07/87023.htm 这是google防止匿名访问连接次数过多而设置的。

解决方法是:浏览器登录https://android.googlesource.com/new-password,输入自己的gmail帐号,点击网页上的“确定”或“允许访问”会得到如下信息(我只找到了确定按键):

企鹅博客
  • 本文由 发表于 2019年9月8日 12:34:05
  • 转载请务必保留本文链接:https://www.qieseo.com/218209.html

发表评论