1. 下载代码
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-8.0.0_r4
repo sync -j2
2. 编译
source build/envsetup.sh
lunch aosp_arm64-eng
make -j4
3. 编译过程中遇到的错误
- 错误1:jdk需要使用open-jdk
************************************************************
You asked for an OpenJDK based build but your version is
java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode).
************************************************************
build/core/main.mk:175: error: stop.
16:00:55 ckati failed with: exit status 1
build/core/main.mk:21: recipe for target 'run_soong_ui' failed
make: *** [run_soong_ui] Error 1
#### make failed to build some targets (54 seconds) ####
解决方案:
配置java环境变量
(1) 使用命令sudo vi /etc/profile打开文件,在文件末尾加入下面三句
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export CLASSPATH=.:$JAVA_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
(2) 使用下面命令使得修改生效
sudo sudo vi /etc/profile
- 错误2:
FAILED: out/host/linux-x86/obj/EXECUTABLES/checkpolicy_intermediates/policy_scan.c
/bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/EXECUTABLES/checkpolicy_intermediates/policy_scan.c external/selinux/checkpolicy/policy_scan.l"
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)
[ 0% 6/78713] Notice file: system/sepolicy/tools/fc_sort/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src/bin/fc_sort.txt
ninja: build stopped: subcommand failed.
16:38:23 ninja failed with: exit status 1
build/core/main.mk:21: recipe for target 'run_soong_ui' failed
make: *** [run_soong_ui] Error 1
#### make failed to build some targets (30 seconds) ####
解决方案:
export LC_ALL=C
- 错误3:
4 warnings generated.
[ 16% 12983/78708] Copy xml: out/target/product/generic_arm64/system/etc/permissions/android.hardware.ethernet.xml
FAILED: out/target/product/generic_arm64/system/etc/permissions/android.hardware.ethernet.xml
/bin/bash -c "(xmllint frameworks/native/data/etc/android.hardware.ethernet.xml >/dev/null ) && (mkdir -p out/target/product/generic_arm64/system/etc/permissions/ ) && (rm -f out/target/product/generic_arm64/system/etc/permissions/android.hardware.ethernet.xml ) && (cp frameworks/native/data/etc/android.hardware.ethernet.xml out/target/product/generic_arm64/system/etc/permissions/android.hardware.ethernet.xml )"
/bin/bash: xmllint: command not found
[ 16% 12984/78708] target C: tcpdump <= external/tcpdump/util.c
ninja: build stopped: subcommand failed.
17:17:14 ninja failed with: exit status 1
build/core/main.mk:21: recipe for target 'run_soong_ui' failed
make: *** [run_soong_ui] Error 1
#### make failed to build some targets (29:33 (mm:ss)) ####
解决方案:
sudo apt-get install libxml2-utils
网友评论