突然心血来潮想下个Android的源码学习下,捣鼓了好一阵子,终于能下载了,总结下下载的问题:
下载说明请参考Android官网url:https://source.android.com/source/downloading.html
步骤及问题汇总如下:
Installing Repo
Repo is a tool that makes it easier to work with Git in thecontext of Android. For more information about Repo, see the Developingsection.
To install Repo:
1. Make sureyou have a bin/ directory in your home directory and that it is included inyour path:
$ mkdir ~/bin $ PATH=~/bin:$PATH
2. Downloadthe Repo tool and ensure that it is executable:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo
如果执行步骤2的时候报:
Protocol https not supported or disabled inlibcurl
是由于你的curl 工具不支持https导致,可以用curl –v 查看一下支持的协议。如果不支持https的话则需要升级一下,centos下的升级方式如下:
下载curl库的代码安装,
./configure –with-ssl
configure结果显示:--with-ssl no
这是因为找不到libssl.so文件。
解决方法:
安装openssl开发库:yum install openssl_devel
之后进入curl库目录,执行./configure –with-ssl configure结果变成了:--with-ssl:enable(OPENSSL)
make; make prefix=/usr/local install
然后通过curl –V查看支持的协议,显示支持了https
Initializing a Repo client
After installing Repo, set up your client to access the Androidsource repository:
1. Create anempty directory to hold your working files. If you're using MacOS, this has tobe on a case-sensitive filesystem. Give it any name you like:
$ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY
2. Run repo init
to bring down thelatest version of Repo with all its most recent bug fixes. You must specify aURL for the manifest, which specifies where the various repositories includedin the Android source will be placed within your working directory.
$ repo init -u https://android.googlesource.com/platform/manifest
To check out a branchother than "master", specify it with -b
. For alist of branches, see Source Code Tags and Builds.
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
3. Whenprompted, configure Repo with your real name and email address. To use theGerrit code-review tool, you will need an email address that is connected witha registeredGoogle account. Make sure this is a live address at which you canreceive messages. The name that you provide here will show up in attributionsfor your code submissions.
A successful initialization will end with a message stating thatRepo is initialized in your working directory. Your client directory should nowcontain a .repo
directory where filessuch as the manifest will be kept.
执行步骤2时,
运行repo init 下载manifest提示:
fatal: git 1.7.2 or later required
这是由于git版本太低,需要升级。方法如下:
git 下载路径 : http://code.google.com/p/git-core/downloads/list
我下载了git-1.9.0 ,通过./configure –prefix=/usr/local安装, make 过程报
cache.h:21: error: expectedspecifier-qualifier-list before ‘z_stream’
这是由于找不到zlib相关的库引起,需要执行如下命令,按照zlib库
yum install zlib-devel 或apt-get install zlib1g-dev(Ubuntu)
git 安装完成后通过git –version检测下版本是否 >1.7.2
紧接着repo init仍然无法成功,提示
fatal: Cannot gethttps://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable
网上说的什么repo版本不对,需要用google账号登录验证都试过,然而并不起作用。
本质原因如下:
你的机器访问不了google,所以会报networkunreach(注意,浏览器能访问不代表机器能访问,测试能不能访问的话得用ping www.google.com ,很多软件只是代理了浏览器的访问而已),怎么支持的话就需要自己设定了。可以通过设定hosts文件或者vpn方式来支持( findspace.name 上有说明,亲测可用)。
设定完成之后,如果pingwww.google.com 能成功,则按照android官网上的说明一步步来就ok了。
另外,步骤repoinit成功的话会提示你输入username和email,按照提示输入即可。
p.s:
如果用的是VMvare的话,需要设置方式为桥接方式,然后更改相应的接口配置文件。参考链接:http://blog.youkuaiyun.com/hero06206/article/details/22936139
Downloading the Android Source Tree
To pull down the Android source tree to your working directoryfrom the repositories as specified in the default manifest, run
$ repo sync
The Android source files will be located in your workingdirectory under their project names. The initial sync operation will take anhour or more to complete. For more about reposync
and otherRepo commands, see theDeveloping section.
这样,android的代码就可以下载了,下载是个漫长的过程,大功告成!