本文主要是介绍ubunt20.4 LineageOS 编译环境搭建,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、服务器准备
建议 ubunt 20.4,有物理机最好,或者用自己电脑的虚拟机。
二、下载repo工具
mkdir -p ~/binmkdir Androidcurl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repochmod a+x ~/bin/repo
三、将~/bin添加到用户执行路径下
vim ~/.profile
#以下内容添加至.profile文件中
# set PATH so it includes user's private bin if it existsif [ -d "$HOME/bin" ] ; thenPATH="$HOME/bin:$PATH"fi
保存后运行
source ~/.profile
四、安装依赖项
sudo apt update
先更新下软件包列表
sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev libelf-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev
有报错解决掉再进行下一步!
lineageOS版本不同所需要的jdk版本也不一样
根据你的设备确认要安装的lineageOS版本https://wiki.lineageos.org/devices/
LineageOS 18.1+:OpenJDK 11
LineageOS 16.0-17.1:OpenJDK 1.9
LineageOS 14.1-15.1:OpenJDK 1.8
LineageOS 11.0-13.0:OpenJDK 1.7
五、配置git
git config --global user.email "you@example.com"git config --global user.name "Your Name"
六、开启缓存加速构建
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccacheccache -M 50G
七、设置lineageOS版本
cd Androidrepo init -u https://mirrors.tuna.tsinghua.edu.cn/git/lineageOS/LineageOS/android.git -b cm-14.1
八、修改官方源为清华源
~/Android/.repo/manifests/default.xml 文件中
将
<remote name="github"fetch=".."review="review.lineageos.org" />
改成
<remote name="github"fetch="https://github.com/" /><remote name="lineage"fetch="https://mirrors.tuna.tsinghua.edu.cn/git/lineageOS/"review="review.lineageos.org" />
将
<remote name="aosp"fetch="https://android.googlesource.com"
改成
<remote name="aosp"fetch="https://mirrors.tuna.tsinghua.edu.cn/git/AOSP"
将
<default revision="..."remote="github"
改成
<default revision="..."remote="lineage"
~/bin/repo 文件中
将
if not REPO_URL:REPO_URL = 'https://gerrit.googlesource.com/git-repo'
改成
if not REPO_URL:REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
修改完后给虚拟机做个快照!
九、开始下载源码
repo sync -j16
-j 按照自己虚拟机配置来,如果遇到错误尝试降低线程。
下载需要一段时间。现在已经完成了第一部分,还需要获取设备独有的二进制文件,后续文档会讲。
报错处理
CA证书相关
Downloading Repo source from https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/
fatal: 无法访问 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/':server certificate verification failed. CAfile: none CRLfile: none
repo: error: "git" failed with exit status 128
设置lineageOS版本时可能会遇到,将https 替换为hppt 配置文件以及 repo init时都需要换。
如果是下载repo工具时遇到,curl 后面加 -k 跳过验证即可。
Python 相关
因为在repo工具中,根据不同的lineageOS版本,也会使用不同版本的python,建议在ubunt中同时安装python2跟python3,sudo apt install 即可,repo会自己调用。如果碰到python语法问题下载完再试一下。
依赖项报错
安装依赖前需要更新下软件包列表。可以使用国内源。出现异常如果解决不了建议全部卸载,更换国内源,update以后重新安装。
编译过程中的依赖报错先不在这里叙述。
这篇关于ubunt20.4 LineageOS 编译环境搭建的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!