1. 下载 repo 工具

mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

2. 建立源码目录

mkdir androidSrc
cd androidSrc

3. 初始化仓库

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest

a) 如果提示无法连接到gerrit.googlesource.com,可以 编辑 repo 文件,

vi ~/bin/repo

把 REPO_URL 一行替换成,

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

b) 如果需要某个特定的 Android 版本,如 android-6.0.1_r46

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-6.0.1_r46

4. 同步源码

repo sync

也可以新建脚本(autoSync.sh)自动同步,

vi autoSync.sh

autoSync.sh内容如下(当连接不上终端时休息3毫秒然后再自动 repo sync),

#!/bin/bash
echo "======start repo sync======"
repo sync
while [ $? == 1 ]; do
echo "======sync failed, re-sync again======"
sleep 3
repo sync
done


04-18 18:37
查看更多