总结一下我从Ubuntu 18.04下编译成功AOSP的过程,以及遇到的坑

我的电脑配置:

OS: Ubuntu 18.04 bionic

Kernel: x86_64 Linux 4.18.0-17-generic

CPU: Intel Core i5-8250U(4核8线程)

RAM: 8G

步骤1:

某些步骤可以先跳过,后面再设置

如果你的电脑也是8G内存(16G可以跳过这个步骤),就需要设置交换空间,否则到后面会出现内存不足的情况,参考:如何在Ubuntu 16.04上增加Swap分区

步骤2:

建议替换国内源:

sudo apt update vim #先安装vim

sudo apt install vim -y

sudo vim /etc/apt/sources.list #或者sudo gedit /etc/apt/sources.list

用#注释所有内容,粘贴以下内容:

 

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
sudo apt update

 

依次安装

sudo apt update

sudo apt install git -y

sudo apt install repo -y

sudo apt install openjdk-8-jdk -y #请输入java -version确认安装正确

步骤3:

清华大学开源软件镜像站下载初始化包(aosp-latest.tar

tar xf aosp-latest.tar #下载完成后解压

cd aosp-latest/aosp

ls -a #应该只有一个.repo隐藏目录

repo sync #检出目录树

可能需要一个小时左右,完成后应该会显示:Syncing work tree:100%(xxx/xxx),done.

ls -a #如下

 

 

步骤4:

安装各种依赖:

sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib -y
sudo apt-get install -y git flex bison gperf build-essential libncurses5-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 -y
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 install make make-guile -y
sudo apt-get install tofrodos -y
sudo apt-get install python-markdown libxml2-utils xsltproc zlib1g-dev:i386

这时可能无法安装libesd0-dev

sudo vim /etc/apt/sources.list

在最后添加:

deb http://kr.archive.ubuntu.com/ubuntu/ xenial main universe
deb-src http://kr.archive.ubuntu.com/ubuntu/ xenial main universe
sudo apt update

sudo apt install libesd0-dev

最后一步:

#export LC_ALL=C添加到~/.bashrc

echo "export LC_ALL=C" >> ~/.bashrc

链接文件

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

重新打开终端

cd到aosp根目录

ls -a #应该是这样

source build/envsetup.sh

lunch aosp_arm64-eng #根据需要输入编译版本 如aosp_x86-eng

#CPU 4核8线程应输入-j8,2核4线程-j4:

make -j8 #开始编译

不出意外,若干小时后应该就会编译成功

 

emulator #启动模拟器

我用i5-8250U编译完成 用了8小时38分(下午3点多开始编译,00点完成)

看来真的该换电脑了 - -!

 

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!