Ubuntu 18.04.1 编译 Android6.0 源码
2018-08-19 本文已影响87人
赶时间的闹钟
Open JDK 安装
- 每个
Android
版本需要对应的OpenJDK
版本,Android 6.0
需要对应的是OpenJDK 1.7
. -
Ubuntu
下载OpenJDK 1.7
$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt-get update
$ sudo apt-get install openjdk-7-jdk
# 或者[参考](https://blog.csdn.net/wanghuasn911/article/details/80155648)
编译环境依赖包
$ 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
$ sudo apt-get install 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
修改源码中编译的条件 ifneq
to ifeq
, true
to false
// line 75
ifneq ($(WITHOUT_HOST_CLANG),true)
// to
ifeq ($(WITHOUT_HOST_CLANG),false)
开始编译三指令
// cd 到源码跟目录
$ source build/envsetup.sh
$ lunch
> aosp_arm64-eng # 选择需要编译的版本
$ make -j8
启动模拟器
# 需要配置源码的 emulator 目录到 PATH
export PATH=$PATH:~/Android-5.0.2_r1/out/host/linux-x86/bin
export ANDROID_PRODUCT_OUT=~/Android-5.0.2_r1/out/target/product/generic
# 变量只对当前登录有效
$ emulator
Tips
- 问题
Error: flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertioncnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
Resoled: export LC_ALL=C