由于下载的时候折腾得有点久,所以写下来跟大家交流一下。

我的下载环境是虚拟机ubuntu11.10,下面是我下载源码的整个过程:

基本是根据http://source.android.com/source/downloading.html的提示进行

Toinstall,initialize,andconfigureRepo,followthesesteps:

Makesureyouhaveabin/directoryinyourhomedirectory,andthatitisincludedinyourpath:

$mkdir~/bin

$PATH=~/bin:$PATH

在下载之前,记得查看是否已经装了git

如果没有的话,可以通过一下命令安装:

$sudoapt-getinstallgit

$sudoapt-getinstallgit-core

确保已经安装git之后,再进行下面的操作。

DownloadtheReposcriptandensureitisexecutable:

$curlhttps://dl-ssl.google.com/dl/googlesource/git-repo/repo>~/bin/repo

$chmoda+x~/bin/repo

AfterinstallingRepo,setupyourclienttoaccesstheandroidsourcerepository:

Createanemptydirectorytoholdyourworkingfiles.Ifyou'reusingMacOS,thishastobeonacase-sensitivefilesystem.Giveitanynameyoulike:

$mkdirWORKING_DIRECTORY

$cdWORKING_DIRECTORY

RunrepoinittobringdownthelatestversionofRepowithallitsmostrecentbugfixes.YoumustspecifyaURLforthemanifest,whichspecifieswherethevariousrepositoriesincludedintheAndroidsourcewillbeplacedwithinyourworkingdirectory.

$repoinit-uhttps://android.googlesource.com/platform/manifest

Tocheckoutabranchotherthan"master",specifyitwith-b:

$repoinit-uhttps://android.googlesource.com/platform/manifest-bandroid-4.0.1_r1

Gettingthefiles

Topulldownfilestoyourworkingdirectoryfromtherepositoriesasspecifiedinthedefaultmanifest,run

$reposync

整个过程下来,估计很多人都是卡在下面的命令那里,我一开始就卡在这里,呵呵。

$repoinit-uhttps://android.googlesource.com/platform/manifest

出现的错误一般如下:

1ExceptioninthreadThread-3:

2Traceback(mostrecentcalllast):

3File"/usr/lib/python2.6/threading.py",line532,in__bootstrap_inner

4self.run()

5File"/usr/lib/python2.6/threading.py",line484,inrun

6self.__target(*self.__args,**self.__kwargs)

7File"/home/haili/android-4.0.4_r1.2/.repo/repo/subcmds/sync.py",line200,in_FetchHelper

8clone_bundle=notopt.no_clone_bundle)

9File"/home/haili/android-4.0.4_r1.2/.repo/repo/project.py",line978,inSync_NetworkHalf

10andself._ApplyCloneBundle(initial=is_new,quiet=quiet):

11File"/home/haili/android-4.0.4_r1.2/.repo/repo/project.py",line1519,in_ApplyCloneBundle

12exist_dst=self._FetchBundle(bundle_url,bundle_tmp,bundle_dst,quiet)

13File"/home/haili/android-4.0.4_r1.2/.repo/repo/project.py",line1583,in_FetchBundle

14raiseDownloadError('%s:%s'%(req.get_host(),str(e)))

15DownloadError:android.googlesource.com:<urlopenerror[Errno110]Connectiontimedout>

16...

其实关于这个文档google有给出解决方法,英文好的直接看文档就明白了。

大概的解决方法如下:

1.浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录;

2.点击网页上的“允许访问”,得到类似:

machineandroid.googlesource.comlogingit-<userName>.gmail.compassword<password>

machineandroid-review.googlesource.comlogingit-<userName>.gmail.compassword<password>

的信息。

3.把上面那段信息(<userName>和<password>用自己得到的真实信息)追加到~/.netrc文件结尾;(补充一下,这里直接用编辑器打开就行了,如$vi~/.netrc,关于这个文件网上有很多人问在哪里。)

4.下载地址的URI更改为https://android.googlesource.com/a/platform/manifest(中间加上了“/a”)。

然后按照官网描述的正常步骤操作,即可拉下Android源码。

官方的说法是:因为访问基本是匿名的,为了防止连接过多,对同一IP地址的连接数做了一定的限制。看来是用gmail帐号进行认证。

这样的话,在公司网络内或者用虚拟机下载的话,会经常遇到这问题。

更多相关文章

  1. Ubuntu 10.04(64位)下载并编译 Android(安卓)2.2 源码[只有11条命
  2. 手把手教你搭建Android开发环境(一)
  3. Android上执行python脚本-QPython
  4. Android(安卓)Source Code
  5. Android(安卓)Studio自动化快速实现Parcelable接口序列化
  6. Android开发插件的下载与安装
  7. android linux镜像文件下载, ubuntu下载地址!
  8. 配置Mac Android(安卓)Studio环境
  9. android 4.2.1 下载和编译

随机推荐

  1. android 云标签,文字墙(文字随机排列效果)
  2. Android SDK 1.5 "--core-library" build
  3. Android通用生命周期
  4. Android的定位策略
  5. cocos2d-x打开网页android与ios平台
  6. android2.1获得联系人信息+Android 获取
  7. android sdk content loader 加载很慢的
  8. Android 日历控件WeekCalendar
  9. android设置eclipse中的自动提示功能
  10. Android防微信表情功能