ubunt20.4 LineageOS 编译环境搭建

一、服务器准备

建议 ubunt 20.4,有物理机最好,或者用自己电脑的虚拟机。


二、下载repo工具

mkdir -p ~/bin

mkdir Android

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

chmod a+x ~/bin/repo

三、将~/bin添加到用户执行路径下

vim ~/.profile

#以下内容添加至.profile文件中

# set PATH so it includes user's private bin if it exists

if [ -d "$HOME/bin" ] ; then

    PATH="$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/ccache

ccache -M 50G

七、设置lineageOS版本 

cd Android

repo 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以后重新安装。

编译过程中的依赖报错先不在这里叙述。


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值