2022ubuntu完美搭建ASOP源码编译环境(国内镜像)1–下载镜像
几个核心地址
https://mirrors.tuna.tsinghua.edu.cn/help/git-repo/ 清华Git Repo 镜像使用帮助
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/ 清华Android 镜像使用帮助
一些相关资料地址
本人环境 全新的ubuntu18
下载整体步骤
1.安装repo
2.安装全局repo 配置文件 repo
3.设更新镜像 3.1
4.新建工作目录 使用 repo init 初始化仓库
5.同步拉下来源码文件 repo sync
6.安装编译环境 包括JDK等一系列的东西
1.安装repo
sudo apt install repo
一路下来就行
2.全局repo文件
按照清华文档来
如果没有curl记得安装一下
sudo apt-get install curl
mkdir ~/bin
PATH=~/bin:$PATH
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
这里修改为清华镜像 下载的更快
3.设置更新镜像地址
sudo gedit ~/.bashrc
新增代码
# repo
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
配置生效
source ~/.bashrc
4.新建工作目录 开始初始化仓库
我们目标明确 是 android8.0_r2 所以直接
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-8.0.0_r2
其他分支打开 https://source.android.com/setup/start/build-numbers#source-code-tags-and-builds 这个网站查询版本代号
当然 不出意外会失败 因为连不上 gerrit.googlesource.com 我们设置一下镜像地址 看步骤3
初始化成功
python3 ~/bin/repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-8.0.0_r2
Your identity is: huruwo <1458476478@qq.com>
If you want to change this, please re-run 'repo init' with --config-name
Testing colorized output (for 'repo diff', 'repo status'):
black red green yellow blue magenta cyan white
bold dim ul reverse
Enable color display in this user account (y/N)? y
repo has been initialized in /home/huruwo/ASOP_8.0_r2
开始同步
repo sync 可以新增一些命令参数
python3 ~/bin/repo sync
然后就是漫长的等待 不过我有200M宽带 估计几个小时就行
完成
Checking out files: 100% (96784/96784), done.
Checking out files: 100% (4867/4867), done.
Checking out files: 100% (3209/3209), done.
Checking out files: 100% (61/61), done.
Checking out files: 100% (1709/1709), done.
Checking out files: 100% (9492/9492), done.
Checking out files: 100% (921/921), done.
Checking out files: 100% (1309/1309), done.
Checking out files: 100% (617/617), done.
Checking out: 100% (568/568), done in 19m53.907s
repo sync has finished successfully.
各种问题出现和解决
1.file=sys.stderr
这个也是最最最多见的错误
我搜了很久才找到完美解决方案
首先这个问题是由于python的版本导致的
我们高版本的ubuntu是默认python3.x的
但是输入python命令还是2.7
比如
python
Python 2.7.17 (default, Feb 27 2021, 15:10:58)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-8.0.0_r2
File "/home/huruwo/ASOP_8.0_r2/.repo/repo/main.py", line 79
file=sys.stderr)
^
SyntaxError: invalid syntax
我们可以打开看看
gdeit /home/huruwo/ASOP_8.0_r2/.repo/repo/main.py
#!/usr/bin/env python3
if sys.version_info.major < 3:
print('repo: error: Python 2 is no longer supported; '
'Please upgrade to Python {}.{}+.'.format(*MIN_PYTHON_VERSION_SOFT),
file=sys.stderr)
sys.exit(1)
可以看到这里是检查了 版本
申明了python2不再支持了
解决方案 我们要把默认的python指向定位3.x而不是2.7
很多地方教我们怎么修改默认的python指向
让python打开和python3命令一样
但是我不建议这么做 不如直接使用python3启动rep的init
更换命令
python3 ~/bin/repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-8.0.0_r2
注意这里指向了文件 ~/bin/repo 而不是默认的路径
2.Please tell me who you are.
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'huruwo@ubuntu.(none)')
小问题 没有输入相关配置信息 按照这两条git命令来一下就行
比如我的
git config --global user.email "1458476478@qq.com"
git config --global user.name "huruwo"
3.证书问题 /etc/ssl/certs/ca-certificates.crt CRLfile: none
/etc/ssl/certs/ca-certificates.crt CRLfile: none
配置忽略证书即可
命令行输入
export GIT_SSL_NO_VERIFY=1