系统:Ubuntu 12.04
安装之前,需要保证安装了git 和 curl,如果没有的话,执行下面命令:
sudo apt-get install git
sudo apt-get install curl
Installing Repo
安装 repo 脚本文件。
注意:在你的 /home/username 目录下面,建立 bin目录,如果想使用方便的话,可以将该目录添加到path中。
我没有这样将其添加到 Path 中,直接在 /home/myname/ 下面建立 /bin 目录。
cd /home/yanxjun
mkdir bin
Download the Repo script and ensure it is executable:
下载 repo 脚本文件到 /home/mark/bin 目录
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
注意:如果,后面操作失败的话,重新下载 repo 文件。
修改文件权限:
chmod a+x ~/bin/repo
新建一个目录 android_src:
cd /home/mark
mkdir android_src
进入 android_src 目录
cd android_src
初始化
~/bin/repo init -u https://android.googlesource.com/platform/manifest
如果想下载指定源码,可以这样:加一个参数 -b:
~/bin/repo init -u https://android.googlesource.com/platform/manifest -b android2.3.7_r1
最后,执行下面命令,开始下载 android 源码:
~/bin/repo sync
等待下载吧,如果中途出现卡死现象,重新执行 ~/bin/repo sync
可能会遇到的问题:
问题1:“A new repo command ( 1.18) is available.”
其实这个问题就是说你本地的repo版本不是1.18,比这个旧,在出现这个的时候,下面会有一个提示你怎么操作的,如:
... A new repo command ( 1.18) is available.
... You should upgrade soon:
cp /home/pn/android/.repo/repo/repo/home/pn/bin/repo(执行这一句就可以),开始我苦悲的上网找这个的解决方法,,,,浪费不少时间。。
问题2:“error: Exited sync due to fetch errors...”
这个问题,网上都说是需要IP认证,其中我也根据
http://blog.youkuaiyun.com/fantao015/article/details/7625559
上面的操作,执行了一遍,其中包括注册了一个@gmail.com邮件,后面发现我没有用到这个也全部下载成功了。
问题3:经常提示
error: Failed connect to android.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.71.82 www.googlesource.com
74.125.71.82 android.googlesource.com
203.208.46.172 cache.pack.google.com
59.24.3.173cache.pack.google.com
然后重新输入
$ repo sync