获取Android源码的简明步骤
3106 点击·0 回帖
![]() | ![]() | |
![]() | 【0】准备环境:Linux or MacOS(也可以选择虚拟机里面安装ubuntu,请注意若是要编译Android源代码,Windows暂不支持). Note:The source download is approximately 6GB in size. You will need 25GB free to complete a single build, and up to 90GB (or more) for a full set of builds. 【1】安装Git与curl: $ sudo apt-get install git-core curl 【2】安装Repo:一个使得Android与Git能够简单工作的工具。 ? 确保在你的home目录下有一个/bin的目录(这个目录其实也可以选择其他位置), 并且把它添加到你的Path路径下: ? $ mkdir ~/bin ? $ PATH=~/bin:$PATH ? 下载Repo脚本并确保它可执行: ? $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo $ chmod a+x ~/bin/repo 【3】初始化Repo: ? 创建一个空的目录来存放你的源文件.你可以像下面一样创建一个目录: ? $ mkdir WORKING_DIRECTORY ? $ cd WORKING_DIRECTORY ? 执行repo init的操作来获取最新的源代码列表。 ? $ repo init -u https://android.googlesource.com/platform/manifest 然后使用 -b 来制定下载哪一个branch:(截至到目前,最新的版本是Android-4.0.4_r1.2) $ repo init -u https://android.googlesource.com/platform/manifest -b Android-4.0.4_r1.2 ? 期间有可能会提示你输入账户名与邮箱,你可以输入你的google帐号(其实可以随便填写一个)。 【4】开始同步下载: ? 执行下面的命令既可(下载过程漫长) $ repo sync 【5】可能遇到的问题: 如果你按上面的步骤执行后发现类似如下的错误: [java] 1. Exception in thread Thread-3: 2. Traceback (most recent call last): 3. File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner 4. self.run() 5. File "/usr/lib/python2.6/threading.py", line 484, in run 6. self.__target(*self.__args, **self.__kwargs) 7. File "/home/haili/Android-4.0.4_r1.2/.repo/repo/subcmds/sync.py", line 200, in _FetchHelper 8. clone_bundle=not opt.no_clone_bundle) 9. File "/home/haili/Android-4.0.4_r1.2/.repo/repo/project.py", line 978, in Sync_NetworkHalf 10. and self._ApplyCloneBundle(initial=is_new, quiet=quiet): 11. File "/home/haili/Android-4.0.4_r1.2/.repo/repo/project.py", line 1519, in _ApplyCloneBundle 12. exist_dst = self._FetchBundle(bundle_url, bundle_tmp, bundle_dst, quiet) 13. File "/home/haili/Android-4.0.4_r1.2/.repo/repo/project.py", line 1583, in _FetchBundle 14. raise DownloadError('%s: %s ' % (req.get_host(), str(e))) 15. DownloadError: Android.googlesource.com: <urlopen error [Errno 110] Connection timed out> 16. ... 那么解决方案如下:(学习自:http://www.atcpu.com/kf/201205/132492.html) 1.浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录; 2.点击网页上的“允许访问”,得到类似: [java] 1. machine Android.googlesource.com login git-<userName>.gmail.com password <password> 2. machine Android-review.googlesource.com login git-<userName>.gmail.com password <password> 3.把上面那段信息(<userName>和<password>用自己得到的真实信息)追加到~/.netrc文件(此文件位于HOME/用户名/.netrc,若不存在可以新建这个文件)结尾; 4.下载地址的URI中添加字段a,如:https://android.googlesource.com/a/platform/manifest。 5.再执行上面的repo init与repo sync命令,即可开始下载。 | |
![]() | ![]() |