在ubuntu 10.04中下载Android源码

详细手册参见:http://source.android.com/source/index.html

1、搭建下载和编译环境
①安装sun-java6-jdk,由于ubuntu官方软件源中已经不包含sun-java6-jdk,需要自己下载安装
②安装相关包,

32bit系统如下:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev libncurses5-dev \
x11proto-core-dev libx11-dev libreadline5-dev libz-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc

64bit系统如下:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc

2、下载源码
①Installing Repo
Make sure you have a bin/ directory in your home directory, and that it is included in your path:
		$ mkdir ~/bin
		$ PATH=~/bin:$PATH

Download the Repo script and ensure it is executable:
		$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
		$ chmod a+x ~/bin/repo

②Initializing a Repo client
Create an empty directory to hold your working files. If you're using MacOS, this has to be on a case-sensitive filesystem. Give it any name you like:
		$ mkdir WORKING_DIRECTORY
		$ cd WORKING_DIRECTORY

Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.
		$ repo init -u https://android.googlesource.com/platform/manifest

To check out a branch other than "master", specify it with -b:
		$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1

Android相关版本以及分支信息参见:http://source.android.com/source/build-numbers.html

③Getting the files
To pull down files to your working directory from the repositories as specified in the default manifest, run
		$ repo sync

出现问题如下:
1、执行repo sync后,提示使用git-core 1.7.2或者更高版本,然后使用ubuntu 10.04的sudo apt-get install git-core安装的版本为1.7.0

解决方法:
打开bin目录下的repo文件,将以下语句
MIN_GIT_VERSION = (1, 7, 2)     # minimum supported git version
改为:
MIN_GIT_VERSION = (1, 7, 0)     # minimum supported git version

2、总是提示http请求失败
error: Failed to connect to 2404:6800:4008:c01::52: Network is unreachable while accessing https://android.googlesource.com/platform/frameworks/compile/libbcc/info/refs  
fatal: HTTP request failed  
error: Failed to connect to 2404:6800:4008:c01::52: Network is unreachable while accessing https://android.googlesource.com/platform/frameworks/compile/linkloader/info/refs  
fatal: HTTP request failed

解决方法:
Using authentication

Google官方指出服务器访问基本是匿名的,为了防止连接过多(指内网/虚拟机),对同一IP地址的连接数做了一定的限制。看来是用gmail帐号进行认证。这样的话,在公司网络内或者用虚拟机下载的话,会经常遇到下载失败的问题。

The first step is to create a password from [https://android.googlesource.com/new-password] and to save it in ~/.netrc according to the instructions on that page.
The second step is to force authenticated access, by using the following manifest URI: https://android.googlesource.com/a/platform/manifest. Notice how the /a/ directory prefix triggers mandatory authentication. You can convert an existing client to use mandatory authentication with the following command:
$ repo init -u https://android.googlesource.com/a/platform/manifest

3、出现在下载过程中卡住的问题


解决方法:
结束此次下载后重新执行 $repo sync


=============== end =================


PS:在下载过程中出现下载失败时,再次执行repo sync就行了。
为了使用方便,可以使用shell脚本循环执行(shell脚本中的$?表示上一个命令的执行结果)

#!/bin/bash  
echo "======start repo sync======"  
repo sync  
while [ $? == 1 ]; do  
echo "======sync failed, re-sync again======"  
sleep 3  
repo sync  
done


经过一晚上的下载终于还是成功了~~~




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值