ubuntu12.04Android源码下载

Downloading the Source

下面是在ubuntu12.04下载android4.0.4源码的操作步骤:

参考官网:http://source.android.com/source/downloading.html

Installing Repo

1.      建立bin目录,并配置环境

$ mkdir ~/bin
$ PATH=~/bin:$PATH

2.      下载repo工具,并赋予其可执行权限

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

 

Initializing a Repo client

1.    建立工作目录,用于存放下载的android源码文件

$ mkdir android4.0.4

$ cd android4.0.4

2.    Check out android的一个分支,比如android4.0.4_r2,执行repo init的操作来获取最新的源代码列表,使用 -b来指定下载哪一个branch

获取分支列表:

$ repo init -u https://android.googlesource.com/platform/manifest

或直接指定分支:

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.4_r2

repo has been initialized in XXXX,表示初始化成功。

如出现网络不可达,可多试几次~

Downloading the Android Source Tree

下载源码:

$ repo sync

期间可能发生中断,停止下载,可以Ctrl+C停掉再用repo sync继续下载,也可以使用一个自动恢复的脚本下载,脚本reposync.sh如下:

#!/bin/sh

repo sync

echo "===== start repo sync====="

while [$? = 1]

do

echo "===== sync failed, re-sync again====="

repo sync

done

         下载过程中,可在源码目录中使用命令du –sh或du –sm查看下载了多少,查看文件和文件夹大小可用命令du -h,可用参数--max-depth指定目录深度,查看当前目录使用的总空间大小du -h --max-depth=0,查看当前及其下一级各目录使用的总空间大小为:du -h --max-depth=1,依次类推。

出现以下信息表示代码下载完成:

Fetching projects: 100% (166/166), done.  

Syncing work tree: 100% (165/165), done.

其它一些事项说明:

1、在源代码下载过程中,我们在源代码下载目录看不到任何文件,打开“显示隐藏”,会看到一个名为.repo的文件夹,这个文件夹是用来保存Android源代码的“临时文件”

2、文件最后下载接近完成时,会从.repo文件夹中导出Android源代码

3、Android源代码下载完成后,我们可以看到Android源代码下载目录中会有

bionic、bootable、build、cts、dalvik......这些文件夹,这些就是Android源代码

4、若是必须关闭电脑停止下载,那么可以在源代码下载的终端中按Ctrl + C 或者 Ctrl + Z 停止源代码的下载,不会造成源代码的丢失或损坏

5、自动或者手动停止源代码的下载,可以使用命令: repo sync 继续下载

 

官方参考:http://source.android.com/source/downloading.html#getting-the-files

 

期间可能遇到的问题及解决方法:

1.      代码下载过程中经常会有如下提示:

error: Failed connect toandroid.googlesource.com:443;Connection refused while accessinghttps://android.googlesource.com/a/platform/frameworks/base/info/refs

fatal: HTTP request failed

error: Cannot fetch platform/tools/motodev

error: Cannot fetch platform/frameworks/base

error: Cannot fetch platform/prebuilts/sdk

error: Exited sync due to fetch errors

 

解决方法:编辑/etc/hosts文件

$ vim /etc/hosts

增加下面内容,保存(提前保存好):

74.125.128.82www.googlesource.com

74.125.31.82android.googlessource.com

203.208.46.172cache.pack.google.com

 

2.      git 版本过低的错误

fatal:git 1.7.2 or later required

解决方法:增加ppa 

$ sudoapt-add-repository ppa:git-core/ppa 

$ sudo apt-getupdate 

$ sudo apt-getinstall git

如果本地已经安装过Git,可以使用升级命令:

$ sudo apt-getdist-upgrade

3.      用户认证问题

error.GitError: manifests var:

*** Please tell me who you are.

Run

 

  git config --globaluser.email "you@example.com"

  git config --globaluser.name "Your Name"

 

to set your account's default identity.

Omit --global to set the identity only in this repository.

 

fatal: empty ident name (for<zhucz@user-desktop.(none)>) not allowed

 

解决方法:

$ git configuser.exmail "xxxxxx@gmail.com"

$ git configuser.name "Xxxx Xx"


git clone: error: RPC failed; result=18, HTTP code = 200 解决办法


curl的postBuffer 默认值较小的原因,配置下个这个值,就不会出现该错误了.

$ git config --global http.postBuffer 24288000

$ git config --list


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值