系统开发 (二)Aosp编译

环境 ubuntu 18.04

一 安装所需依赖

sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig

参照官方文档

系统开发 (二)Aosp编译_第1张图片

二 JDK环境

sudo apt-get install openjdk-8-jdk

sudo vim /etc/profile

追加

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre 
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib 
export PATH=${JAVA_HOME}/bin:$PATH

三  编译过程中的错误处理


1  flex-2.5.39: loadlocale.c:130:_nl_intern_locale_data: ?? ‘cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))’ ???
Aborted (core dumped)

解决办法:
在~/.bashrc最后添加export LC_ALL=C     (  去除本地C化,使得Android的编译工具与本地工具不冲突。)
然后 source ~/.bashrc

// 注意恢复 export LC_ALL=C

2 Jack server failed to (re)start, try 'jack-diagnose' or see Jack server log
SSL error when connecting to the Jack server. Try 'jack-diagnose'
SSL error when connecting to the Jack server. Try 'jack-diagnose'
[ 29% 9406/31906] target thumb C++: libandroid_runtime <= frameworks/base/core/jni/android/graphics/pdf/PdfEditor.cpp
In file included from external/pdfium/core/include/fpdfapi/fpdf_module.h:10:0,

解决办法:

Remove TLSv1, TLSv1.1 from jdk.tls.disabledAlgorithms in /etc/java-8-openjdk/security/java.security file
Restart the jack server: cd /prebuilts/sdk/tools/ ./jack-admin kill-server ./jack-admin start-server 
 

curl - Rebuild android code with error “SSL error when connecting to the Jack server. Try 'jack-diagnose” - Stack Overflow

3 Out of memory

Out of memory error (version 1.2-rc4 'Carnac' (298900 f95d7bdecfceb327f9d201a1348397ed8a843843 by [email protected])).
GC overhead limit exceeded.
Try increasing heap size with java option '-Xmx'.

fix

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server 

四 编译 Android  Soong 编译系统 

使用 envsetup.sh 脚本初始化环境:

source build/envsetup.sh

选择目标

lunch

使用 lunch 选择要构建的目标。lunch product_name-build_variant 会选择 product_name 作为需要构建的产品,并选择 build_variant 作为需要构建的变体,然后将这些选择存储在环境中,以便供后续对 m 和其他类似命令的调用读取。

lunch aosp_arm-eng

make -j8       

//    m (make systemimage)  mm mma

make:根据lunch选项,编译Android系统,最后产出为:system.img,ramdisk.img,userdate.img
m:和make命令一样
mm:从当前目录下开始向下编译目标
mmm:指定一个目录,仅编译指定目录下的目标
make snod:只将out/target/product/XXX/system/目录下的内容打包生成system.img,不会检查依赖关系
make bootimage:只将out/target/product/XXX/root/目录下的内容打包生成ramdisk.img

//编译生成 system.img  userdata.img ramdisk.img 

系统开发 (二)Aosp编译_第2张图片

你可能感兴趣的:(Framework,ubuntu,linux,aosp)