ubuntu 11.04+获取Android源码




1.避免选择wubi安装ubuntu系统(不稳定,可能导致编译失败)。


2.在安装开发过程中所需要的一些开发包时,为避免编译过程中遇到些莫名问题,在先前所说基础上,建议安装以下包:


$ sudo apt-get install lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6


3.安装java环境时,选择在线安装方式会更方便。因为它会安装sun-java6-bin和sun-java6-jre,自动配置编译环境。


 


以下是修改后的完整过程总结:


Attention:本文环境是在ubuntu 11.04+下获取并编译android 2.3.3_r1的源码,记录下过程,方便自己备份的同时也希望能对后来者有所帮助。


官网上的要求信息为:


In general you will need:


Python 2.4 -- 2.7, which you can download from python.org.


JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from java.sun.com.


Git 1.7 or newer. You can find it at git-scm.com.


一、下载前准备工作


Note: The source download is approximately 6GB in size. You will need 25GB free to complete a single build, and up to 80GB (or more) for a full set of builds.


1.首先,准备好所需磁盘空间后,就来安装开发过程中需要的一些开发包,在终端中执行以下命令:


$ 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 libreadline6-dev libgl1-mesa-dev tofrodos python-markdown libxml2-utils lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6
2.安装java环境


安装Java 6,因为在现在的ubuntu系统包库里,已经不再包含JDK,因此我们需要手动添加库,执行如下命令:


$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
之前安装jdk时,官网上给出了两条添加库语句,第二条


$ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
是会提示错误的


Error: 'deb-src http://archive.canonical.com/ lucid partner' invalid
昨天再看官网已经更新了,去掉了这一条,很给力啊有木有~


 


二、开始下载源码(这部分同ubuntu 11.04下android源码的获取http://www.cnblogs.com/dwayne/archive/2011/11/11/2245383.html)


现在我们已经准备好了android源码开发所需的环境(无错误),下载源码的过程由于Android的源码很是庞大,需要分Android源码和内核两部分获取。内核部分的源码我暂时是不用的,所以这里只下载源码。


1.先新建一个文件夹存放Android目录,并初始化repo:




wayne @ubuntu :~$ mkdir Android
wayne @ubuntu :~$ cd Android
wayne @ubuntu :~/Android$ mkdir bin
wayne @ubuntu :~/Android$ cd bin
wayne @ubuntu :~/Android/bin$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo >repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19731  100 19731    0     0  14034      0  0:00:01  0:00:01 --:--:-- 17157




在这里,几个月前http://android.git.kernel.org/已经无法访问了,很多朋友如果用的是这个源下载站点,就会出现如下情况:


wayne @ubuntu :~/Android/bin$ curl http://android.git.kernel.org/repo >repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   244  100   244    0     0     75      0  0:00:03  0:00:03 --:--:--   976
然后在之后的代码初始化时就会出现如下错误:


./bin/repo: 行 1: 未预期的符号 `newline' 附近有语法错误
./bin/repo: 行 1: `<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'
2.现在继续。建立存放源码目录source,初始化所需的android源码版本,在终端执行如下命令:




wayne @ubuntu :~/Android/bin$ sudo chmod a+x repo
wayne @ubuntu :~/Android/bin$ cd
wayne @ubuntu :~$ cd Android/source/
wayne @ubuntu :~/Android/source$ ../bin/repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.3_r1
gpg: 钥匙环‘/home/wayne/.repoconfig/gnupg/secring.gpg’已建立
gpg: 钥匙环‘/home/wayne/.repoconfig/gnupg/pubring.gpg’已建立
gpg: /home/wayne/.repoconfig/gnupg/trustdb.gpg:建立了信任度数据库
gpg: 密钥 920F5C65:公钥“Repo Maintainer <repo@android.kernel.org>”已导入
gpg: 合计被处理的数量:1
gpg:               已导入:1


Get https://android.googlesource.com/tools/repo
remote: Counting objects: 1414, done
remote: Finding sources: 100% (78/78)
remote: Total 1414 (delta 917), reused 1414 (delta 917)
Receiving objects: 100% (1414/1414), 429.88 KiB | 169 KiB/s, done.
Resolving deltas: 100% (917/917), done.
From https://android.googlesource.com/tools/repo
 * [new branch]      maint      -> origin/maint
 * [new branch]      master     -> origin/master
 * [new branch]      stable     -> origin/stable
...


这样下来之后,会要求输入用户名和邮箱地址,随意写个就ok。


初始化完毕之后会出现:


repo initialized in /home/wayne/Android/source
现在完成初始化之后便可以下载了,在终端执行如下命令,开始下载:


wayne @ubuntu :~/Android/source$ ../bin/repo sync
下载全部的源码需要很长时间,现在正在经历漫长的等待……


过程中时常看一下,也许会出错而中断:


error: Exited sync due to fetch errors
遇到这些问题时,重新执行一遍../bin/repo sync就ok。




Fetching projects: 100% (165/165), done.
Checking out files: 100% (3573/3573), done.ut files: 30% (1078/3573)
Checking out files: 100% (4679/4679), done.out files: 33% (1580/4679)
Checking out files: 100% (10008/10008), done.t files: 23% (2370/10008)
Checking out files: 100% (11980/11980), done.t files: 0% (64/11980)
Checking out files: 100% (9601/9601), done. out files: 0% (67/9601)
Syncing work tree: 100% (165/165), done.  


下载完成。接下来就是编译源码了,敬请期待。

转载于:https://my.oschina.net/arthurdu/blog/115143

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值