linux下载android源码的若干问题

本周开始看《深入理解android卷一》这本书,在第一章下载android源码这一部分遇到过比较多的问题,纠结了很久才下到android源码。

现将其中遇到的问题归纳如下:

在书中,下载anroid的代码如下:

这个代码过于古老,现在已经没法用了。我们到谷歌android下载的主页可以看到新的下载代码。

这个代码可以下载到最新的android代码。

但是,如果你使用虚拟机下载(我使用的是ubuntu虚拟机)时,任然会出现问题。

问题1

但是在repo 初始化过程中却遇到一个问题
/root/bin/repo line 1: syntax error near unexpected token `newline'
以前也下过源码,却没有碰到过这种问题
经过测试,重新下载
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ repo init -u https://android.googlesource.com/platform/manifest
$ repo sync
注意这里是https ,不是http
开始写成http的时候就产生了上面的问题

问题2

报错

看这出错很莫名,Python是正确安装了的,版本也是要求的。其实官网(http://source.android.com/source/downloading.html)有段说明,如果认真执行就可解决。
1. 浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录;
2. 点击网页上的“允许访问”,得到类似:
的信息。
3. 把上面那段信息(<userName>和<password>用自己得到的真实信息)追加到~/.netrc文件结尾;
4. 下载地址的URI更改为https://android.googlesource.com/a/platform/manifest(中间加上了“/a”)。
然后按照官网描述的正常步骤操作,即可拉下Android源码。
官方的说法是:因为访问基本是匿名的,为了防止连接过多,对同一IP地址的连接数做了一定的限制。看来是用gmail帐号进行认证。这样的话,在公司网络内或者用虚拟机下载的话,会经常遇到这问题。
问题3

报错

error: git was compiled without libcurl support
这一部分主要git版本太低引起的,如果是1.7以上版本则应该没有此错误。

其解决方法为:

The solution is to add backports.debian.org/debian-backports [A] to your /etc/apt/sources.list like this:
# vi /etc/apt/sources.list
And add the following line
deb http://backports.debian.org/debian-backports lenny-backports main

Get packages upgraded from backports.debian.org (Recommended!)
This setting is recommended Without this setting you don't get security updates
Replacing backports.debian.org/debian-backports with the mirror in question.
Normally packages won't get upgraded automatically from backports.debian.org (due to the NotAutomatic flag). To get packages that you have installed from backports automatically updated you have to have add a pinning, either to /etc/apt/preferences:
Package: *
Pin: release a=lenny-backports
Pin-Priority: 200

Replacing backports.debian.org/debian-backports with the mirror in question.
# apt-get update
# apt-get upgrade
# apt-get -t lenny-backports install git

Now git version should be "git version 1.7.1"

# git --version
git version 1.7.1

if not please check
$ /usr/bin/git --version
$ /usr/local/bin/git --version
HACK: Then copy the new version on the old one [B]
# sudo cp /usr/bin/git /usr/local/bin/git
[A] For more info about Debian backports see http://backports.debian.org/Instructions/
[B] if you have a better idea please email me


你可能感兴趣的:(Android源码)