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 主線版本


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM