Aosp源码拉取

87 阅读1分钟

aosp项目拉代码

推荐使用Ubuntu系统,网上资源比较多。win系统可以尝试使用docker技术。

1.拉取代码

1.准备

  • ubuntu系统18.04.1

2.网站

由于网络限制,使用国内源比较方便。下面使用的是清华大学提供的源。
清华大学 mirrors.tuna.tsinghua.edu.cn/help/AOSP/

3.拉代码

  • 第一步:安装git

    sudo apt-get install git 下载git
    git config --global user.email "yourmail" 配置email
    git config --global user.name "yourname" 配置name

  • 第二步:安装repo

    1.mkdir ~/bin 在~目录下创建bin

    2.PATH=~/bin:$PATH 将repo加入到PATH环境,类似于win系统添加环境变量

    3.curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo 将下载的repo放在 ~/bin/repo路径下

    4.chmod a+x ~/bin/repo 给所有用户可执行权限

    注意: 只有PATH下存在repo的存放路径,repo命令才能执行。(可以研究下Ubuntu环境变量配置)

  • 第三步:拉取aosp源码

repo init -u <https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest> -b android-13.0.0_r31

repo sync

4 问题点

    1. repo init失败原因

python版本和repo不兼容

网络问题:使用repo运行会使用到全局变量REPO_URL。
如果系统变量未配置,会使用默认的链接: gerrit.googlesource.com/git-repo
由于此链接国内无法使用也会报错,所以此处需要配置清华链接地址系统变量。
配置方式:mirrors.tuna.tsinghua.edu.cn/help/git-re…

image.png