《android源码阅读二》android源码下载

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_28779083/article/details/82697786

网上关于这块大部分教程都是无效的,因为墙的缘故,我这里使用了清华大学的镜像。

1、下载 repo

  • Repo 是一款工具,可让您在 Android 环境中更松地使用 Git,首先需要安装Git:
sudo apt-get install git
  • 创建 bin,并加入 path:
mkdir ~/bin
PATH=~/bin:$PATH
  • 下载 repo:
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
  • 此时可能遇到错误:
Command 'curl' not found, but can be installed with:
sudo apt install curl

需要安装 curl,执行命令 sudo apt-get install curl  进行安装。
注意:命令  apt  在低版本 Ubuntu 不行,本教程统⼀使用命令  apt-get  。
  • 权限设置:
chmod a+x ~/bin/repo

2、验证repo 安装成功

  • 输入命令 repo ,提示:
/usr/bin/env: "python": 没有那个文件或目录

需要安装 python,执行命令 sudo apt-get install python  安装
  • 再次输入命令 repo ,提示如下即 repo 安装成功:
error: repo is not installed. Use "repo init" to install it here.

3、下载源码

  • 建立工作目录AOSP,命令:
mkdir AOSP
cd AOSP
  • 初始化仓库:
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
  • 此时可能会出现以下错误:
//错误1:

error.GitError: manifests var:
*** 请告诉我你是谁。
运⾏行行
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
来设置您账号的缺省身份标识。
如果仅在本仓库设置身份标识,则省略略 --global 参数。

//错误2:

fatal: Cannot get https://gerrit.googlesource.com/git-
repo/clone.bundle
fatal: error [Errno 101] Network is unreachable

因为 repo 运⾏过程中会尝试访问官方的 git 源更新自⼰,如果想使⽤tuna的镜像
源进⾏更新,将如下内容复制到你的 ~/.bashrc ⾥,然后重启终端模拟器器。
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'

//*注意: .bashrc默认是隐藏的文件,需要按Ctrl+H显示隐藏文件。
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-8.0.0_r1
  • 同步源码树(以后只需执⾏这条命令来同步):
repo sync
  • 然后等待下载完毕:
正在检出⽂文件: 100% (1709/1709), 完成.
正在检出⽂文件: 100% (9492/9492), 完成.在检出⽂文件: 2% (251/9492)
正在检出⽂文件: 100% (617/617), 完成.正在检出⽂文件: 17% (106/617)
正在检出⽂文件: 100% (15779/15779), 完成.检出⽂文件: 7% (1251/15779)
正在检出⽂文件: 100% (29/29), 完成. 正在检出⽂文件: 27% (8/29)
Syncing work tree: 100% (568/568), done.

参考知识星球: 吴小龙同学

猜你喜欢

转载自blog.csdn.net/qq_28779083/article/details/82697786