参考:http://source.android.com/source/downloading.html html
红色字体表示多项选择中,我所作的选择 android
安装curl工具 git
$ sudo apt-get install curl ubuntu
git工具的安装(按照以下方式安装最新版) api
增长ppa bash
$ sudo apt-add-repository ppa:git-core/ppa 网络
$ sudo apt-get update curl
$ sudo apt-get install git 工具
git的版本号就是最新的 字体
$ git --version
git version 1.8.5.2
错误:sudo apt-add-repository ppa:git-core/ppa时出现错误:gpg: requesting key E1DF1F24 from hkp server keyserver.ubuntu.com / gpgkeys: HTTP fetch error 7: couldn't connect to host
缘由:keyserver.ubuntu.com使用非标准的11371端口,而通常公司的防火墙都屏蔽掉了该端口,而容许标准的80端口。
因此能够以以下方式强行使用80端口添加软件源:
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 E1DF1F24
绿色部分是你要请求的Key.
repo工具的下载
google是这样告诉咱们的:
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
可是好像是不能访问
解决方法:http://code.google.com/p/git-repo/downloads/detail?name=repo-1.12 这个连接提供下载repo!
也能够经过下面命令获得:
$ curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo
我是用在http后面加了个s下载的1.20,竟然能够,没有其余版本出的错误
$ curl https://commondatastorage.googleapis.com/git-repo-downloads/repo > ./repo
具体的repo版本能够去查看http://code.google.com/p/git-repo/downloads 页面上的信息,下载那个版本都行。
修改执行权限
$ chmod a+x repo
repo init 建立仓库
初始化android 源代码,下载最新代码
$ ./repo init -u https://android.googlesource.com/platform/manifest
或者像这样取得某个分支如android-4.4.2_r1
$ ./repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.2_r1
若是须要下载其余分支将android-4.4.2_r1改为其余分支名称就能够了。分支名称请在https://android.googlesource.com/platform/manifest/+refs 里面查看branch
执行repo sync 进行同步
$ ./repo sync
使用repo sync同步下载代码时由于网络缘由可能会常常断线,可使用下面的脚原本作个脚本文件,让它中断后,又自动下载
建立脚本download.sh
#!/bin/bash
echo "=========start repo sync=============="
./repo sync
while [ $? == 1 ]; do
echo "======sync failed, re-sync again======"
sleep 3
./repo sync
done
chomd a+x download.sh让其能够运,而后终端输入./download.sh就能够开始下载了,用这一步代替官方文档里的repo sync。当链接不上终端时休息3毫秒而后再自动repo sync。
下载完成后,下一步就是编译了