Android10 源码编译

目录

  1. 源码下载
  2. 环境搭建
  3. 源码编译
  4. 遇到的问题记录

源码下载

源码下载请看之前写的博客AOSP Android 源码下载教程

环境搭建

我是 Ubuntu20.04 上边编译 Android10.0.0_r33 , Ubuntu 18.04 步骤基本一致。

  • 安装 openjdk8
sudo apt-get install openjdk-8-jdk
  • 安装依赖库
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

建议逐行安装,我这边安装时提示缺少 libesd0-dev ,直接去掉这个包的安装即可,不会对后续的编译过程产生影响。

源码编译

1、cd 到源码根目录下边
2、source build/envsetup.sh  
3、lunch 选择自己需要编译的版本
4、make  等待编译成功

编译过程描述不是很详细,因为大同小异,并且百度一大堆,所以无需赘述。

遇到的问题记录

  1. libncurses.so.5 和 libtinfo.so.5 找不到
error while loading shared libraries:libncurses.so.5: cannot open shared object file:No such file or directory
error while loading shared libraries: libtinfo.so.5: cannot open shared object file:No such file or directory

解决思路:
库找不到有两种可能,一种就是没有安装(sudo find -name “libncurses.so.5” 在系统根目录下查找),另外一种就是安装了但是没有配置到系统查找路径中。
我这边搜索发现在 Android10 源码中就有着两个文件,所以我直接建立了两个软连接让系统可以搜索到即可。

sudo ln -s /home/cxp/work/aosp_android0.0.0_r33/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot/usr/lib/libncurses.so.5  /lib/libncurses.so.5
sudo ln -s /home/cxp/work/aosp_android0.0.0_r33/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot/usr/lib/libtinfo.so.5  /lib/libtinfo.so.5
  1. api 问题
Killed
-e
******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
   1. You can add '@hide' javadoc comments to the methods, etc. listed in the
      errors above.

   2. You can update current.txt by executing the following command:
         make system-api-stubs-docs-update-current-api

      To submit the revised current.txt to the main Android repository,
      you will need approval.
******************************

这个问题的解决方法已经在提示中了,就是执行

make system-api-stubs-docs-update-current-api

然后重新编译即可。

  1. 创建system-qemu.img失败
FAILED: Create system-qemu.img now
Outputs: out/target/product/generic_x86_64/system-qemu.img
Error: exited with code: 1
Command: /bin/bash -c "(export SGDISK=out/host/linux-x86/bin/sgdisk SIMG2IMG=out/host/linux-x86/bin/simg2img;      device/generic/goldfish/tools/mk_combined_img.py -i out/target/product/generic_x86_64/system-qemu-config.txt -o out/target/product/generic_x86_64/system-qemu.img)"
Output:
  File "device/generic/goldfish/tools/mk_combined_img.py", line 52
    print "'%s' cannot be converted to int" % (line[2])
          ^
SyntaxError: invalid syntax

这个错误是一个 python 脚本中报错,是因为这个脚本是使用 python2 编写,我本地默认是 python3,python3 中 print 必须要加括号,所以报错。
两种修改方式:
1、修改脚本执行的python版本,#/usr/bin/python 改为 #/usr/bin/python2
2、修改软连接 /usr/bin/python 指向 /usr/bin/python2

这两种修改方案成功的前提是你本地已经安装了 python2 为前提。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值