ubuntu 20.04编译Android源码

        一直以来想编译android源码,趁闲编译了下,ubuntu版本:20.04,android源码版本:android-9.0.0_r30。总体还比较顺畅,中间遇到了一些报错,在文中也有记录,详情见下文。

代码仓库配置

配置

sudo apt-get install git-core

sudo apt-get install git-core curl 

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

 报错换国内的

curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo

  • 修改权限

chmod a+x ~/bin/repo

  • 配置环境变量

sudo gedit .bashrc

  • 在配置文件尾部加入

export REPO_URL=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/ 

如:

  • 执行source .bashrc 是配置生效

执行

  • repo init

报错:/usr/bin/env: “python”: 没有那个文件或目录

 

 sudo apt install python2

 sudo ln -s /usr/bin/python2 /usr/bin/python

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

 还是失败

替换路径

将REPO_URL修改国内可访问路径“https://mirrors.tuna.tsinghua.edu.cn/git/git-repo”,如下

REPO_URL = os.environ.get('REPO_URL', None)
if not REPO_URL:
REPO_URL = 'https://gerrit.googlesource.com/git-repo'

修改为https://mirrors.tuna.tsinghua.edu.cn/git/git-repo

再次执行 

 

 repo has been initialized in /home/sunnyin  既成功
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-9.0.0_r30

  • 清空缓存 以及同步

find . -iname tmp_pack_* | xargs rm
repo sync -j4

  •  安装依赖库
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib
sudo apt-get install libc6-dev-i386
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo apt-get install lib32z-dev ccache
sudo apt-get install libssl-dev
  •  执行

source build/envsetup.sh

lunch查看编译目标

user:用来正式发布到市场的版本,权限受限,如没有 root 权限,不能 dedug,adb默认处于停用
userdebug:在user版本的基础上开放了 root 权限和 debug 权限,adb默认处于启用状态。一般用于调试真机。
eng:开发工程师的版本,拥有最大的权限(root等),具有额外调试工具的开发配置。一般用于模拟器。

lunch 5

  •  开始编译

make -j4

报错

prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++.real: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

解决:

sudo apt-get install libncurses* 

启动模拟器

执行emulator

参考资料

https://blog.csdn.net/a992036795/article/details/53462068

https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

https://blog.csdn.net/u014078003/article/details/122398618

https://juejin.cn/post/6844903811304325127

https://www.bilibili.com/video/BV15u411o7Ko?spm_id_from=333.337.search-card.all.click

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值