AOSP android7.1.1-r16源码编译

编译环境配置

Ubuntu17.04

安装openjdk(7/8/9)

sudo apt-get install openjdk-8-jdk

安装git

sudo apt-get install git

git config --global user.name "accout"

git config --global user.email "accout @qq.com"

sudo apt-get install repo

添加依赖

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

 

 

 

获取源码

Android7.1

repo工具准备

mkdir ~/bin

PATH=~/bin:$PATH

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

chmod a+x ~/bin/repo

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

chmod +x repo

建立源码文件

mkdir source

cd source

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest   // 最近版本

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.1_r16   // 指定版本

// 细分版本 NUF26K

repo sync

备注

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.1_r16

repo init -u git://aosp.tuna.tsinghua.edu.cn/aosp/platform/manifest -b android-7.1.1_r16

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.1_r24

 

编译源码

编译

编译工程

source build/envsetup.sh

lunch aosp_arm64-eng

make -j8

编译模块

. build/envsetup.sh

m:编译所有的模块

mm:编译当前目录下的模块,当前目录下要有Android.mk文件

mmm:编译指定路径下的模块,指定路径下要有Android.mk文件

!!!编译前需执行:. build/envsetup.sh,否则报错找不到命令xx

ref:link

 

 

 

参考:

     获取源码

     清华大学开源软件镜像站

     Codenames, Tags, and Build Numbers 主线版本

     网盘下载

     编译

     自己动手编译Android源码(超详细)

     打造自己的Android源码学习环境之五:编译Android源代码

     烧录

     从谷歌官网下载android 6.0源码、编译并刷入nexus 6p手机

     Factory Images for Nexus and Pixel Devices

     将android-6.0.1_r11的编译结果刷入nexus6P

     Ubuntu 14.04 编译 AOSP for Nexus/Pixel

 

编译问题

Q1.首次编译报错(Ubuntu14.04-Android6.0)

Log: ERROR: Bad request, see Jack server log (/tmp/jack-envy15/jack-8072.log)

 

Q2.首次编译报错GC overhead limit exceeded (Ubuntu17.04-Android7.1)

关键Log:

Out of memory error (version 1.3-rc6 'Douarn' (441800 22a11d4b264ae70e366aed3025ef47362d1522bb by android-jack-team@google.com)).

GC overhead limit exceeded.

Try increasing heap size with java option '-Xmx<size>'.

// android-7.1.1_r16

FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/core-all_intermediates/with-local/classes.dex.rsp

Out of memory error (version 1.2-rc4 'Carnac' (298900 f95d7bdecfceb327f9d201a1348397ed8a843843 by android-jack-team@google.com)).

Java heap space.

Try increasing heap size with java option '-Xmx<size>'.

Warning: This may have produced partial or corrupted output.

解决方案:

Out of memory error(2次)

方法1

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"

out/host/linux-x86/bin/jack-admin kill-server

out/host/linux-x86/bin/jack-admin start-server

 

Q3.首次编译权限报错(Ubuntu17.04-Android7.1)

关键Log:

opendir failed: .dbus: Permission denied

解决方案:

Permission denied

方法1

sudo chmod 777 e2670/ -R

 

Q4.编译报错无效UTF-8字符(Ubuntu17.04-Android7.1)

关键Log:

art/runtime/interpreter/unstarted_runtime.cc:1517:1: error: source file is not valid UTF-8

解决方案:

UTF-8字符集错误

方法1

参考GOOGLO代码修正错误

Google-code

 

Q5.报错fatal: fork: Cannot allocate memory (Ubuntu17.04-Android7.1)

关键Log:

[  3% 802/22494] Install: out/target/p...duct/angler/system/app/Music/Music.apk

ninja: fatal: fork: Cannot allocate memory

build/core/ninja.mk:148: recipe for target 'ninja_wrapper' failed

make: *** [ninja_wrapper] Error 1

解决方案:

无法分配内存(2次)

方法1

sysctl kernel.pid_max   // 查看最大进程数

ps -eLf | wc –l   // 查看运行进程数

// 修改最大进程数后系统恢复

echo 1000000 > /proc/sys/kernel/pid_max

// 永久生效

echo "kernel.pid_max=1000000 " >> /etc/sysctl.conf

sysctl –p

结果:无权限修改最大进程数

方法2

查看虚拟机内存分配只有6G左右,关闭虚拟机内存调整到8G,编译正常。

Ref:

    -bash: fork: Cannot allocate memory 问题的处理

 

Q6. Communication error with Jack server (52).(Ubuntu17.04-Android7.1)

关键Log:

[ 14% 3153/21625] Building with Jack: ...k_intermediates/with-local/classes.dex

FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp

Communication error with Jack server (52). Try 'jack-diagnose'

[ 14% 3153/21625] target  C++: sgdisk <= external/gptfdisk/gptcl.cc

external/gptfdisk/gptcl.cc:36:29: warning: unused parameter 'filename' [-Wunused-parameter]

GPTDataCL::GPTDataCL(string filename) {

                            ^

external/gptfdisk/gptcl.cc:109:43: warning: missing field 'descrip' initializer [-Wmissing-field-initializers]

      POPT_AUTOHELP { NULL, 0, 0, NULL, 0 }

                                          ^

2 warnings generated.

ninja: build stopped: subcommand failed.

build/core/ninja.mk:148: recipe for target 'ninja_wrapper' failed

make: *** [ninja_wrapper] Error 1

解决方案:

Communication error with Jack server

方法1

jack-admin start-server

Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/galian/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher

结果:command not found

方法2

jack-admin start-server

ref:link

Ref:

     打造自己的Android源码学习环境之五:编译Android源代码

     Android7.0 JACK编译器不支持多用户同时编译的问题的解决

 

Q7. The program 'mm' is currently not installed.(Ubuntu17.04-Android7.1)

关键Log:

The program 'mm' is currently not installed. You can install it by typing:

sudo apt install multimail

解决办法:

. build/envsetup.sh

Ref:

     使用mm/mmm 准备工作

 

参考:

     AOSP

     Codenames, Tags, and Build Numbers 主线版本

posted @ 2017-06-13 23:29  zhen-Android  阅读(4190)  评论(0编辑  收藏  举报