首页 > 技术文章 > 简记Ubuntu下载 Android源码

benchao 2017-03-31 22:29 原文

1.下载Ubuntu系统,推荐16.04以上版本;

2. git : 使用repo工具的时候会用到git,要预先安装git,使用命令:sudo apt-get install git 

3. 安装git后,对git进行配置,设置git电子邮件和用户名

  (1) git config --global user.email "你的电子邮件" 

  (2) git config --global user.name "你的名字"

4. 安装curl (开源文件传输工具) , 使用命令: sudo apt-get install curl -y

5. 重要环节 : 下载repo

下载repo之后,将repo的路径设为环境变量,并且将权限改成可执行
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

6. 接下来新建一个目录,用于放置Android源码,并进入该目录如下:

   (1) mkdir android

   (2) cd android

7. 使用repo初始化

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest

如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo,把 REPO_URL 一行替换成:

REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

如果你只想下载特定的android版本,可以使用如下命令:

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b  Android版本 (比如:android-7.1.1_r13)

8. 下载代码,命令如下 (注:这个过程很耗时间)

repo sync  

推荐阅读