Ubuntu 22.04 Android 配置系统编译环境

android 7.1 ~ android 12

Posted by LXG on January 12, 2023

建立构建环境-AOSP

AOSP

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

问题 1


/home/lxg/code/project/A133_android_10/longan/build/mkcmd.sh: line 330: python: command not found
ERROR: Can't find kernel defconfig!

scripts/kconfig/conf  --defconfig Kconfig
***
*** Can't find default configuration "arch/arm64/defconfig"!
***
make[1]: *** [scripts/kconfig/Makefile:100:defconfig] 错误 1
make: *** [Makefile:560: defconfig] Error 2
ERROR: build kernel Failed
INFO: mkkernel failed
Build kernel failed!

解决方法

sudo apt install python

问题 2


/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:110:scripts/dtc/dtc] 错误 1
make[1]: *** [scripts/Makefile.build:648:scripts/dtc] 错误 2
make[1]: *** 正在等待未完成的任务....
  HOSTLD  scripts/mod/modpost
make: *** [Makefile:574: scripts] Error 2
make: *** Waiting for unfinished jobs....
  CHK     include/generated/bounds.h
  UPD     include/generated/bounds.h
  CC      arch/arm64/kernel/asm-offsets.s
  CHK     include/generated/asm-offsets.h
  UPD     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
ERROR: build kernel Failed
INFO: mkkernel failed
Build kernel failed!

解决方法:降低gcc版本

  1. sudo apt install gcc-9 g++-9
  2. sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-9 100
  3. sudo update-alternatives –install /usr/bin/g++ g++ /usr/bin/g++-9 100
  4. sudo make distclean

问题 3


scripts/extract-cert.c:21:10: fatal error: openssl/bio.h: 没有那个文件或目录
   21 | #include <openssl/bio.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [scripts/Makefile.host:90:scripts/extract-cert] 错误 1
make[1]: *** 正在等待未完成的任务....

解决方法

sudo apt-get install libssl-dev

问题 4


/bin/sh: 1: lz4c: not found
make[1]: *** [arch/arm64/boot/Makefile:31:arch/arm64/boot/Image.lz4] 错误 1
make: *** [arch/arm64/Makefile:139:Image.lz4] 错误 2

sudo apt-get install liblz4-tool

问题 5


************************************************************
You are attempting to build with the incorrect version
of java.
 
Your version is: /bin/bash: 行 1: java:未找到命令.
The required version is: "1.8.x"
 
Please follow the machine setup instructions at
    https://source.android.com/source/initializing.html
************************************************************

解决方法

sudo apt-get install openjdk-8-jdk openjdk-8-jre openjdk-8-doc

问题 6

问题与修改方法


FAILED: /bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_l.cpp system/tools/aidl/aidl_language_l.ll"
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)

解决方法

  1. prebuilts/misc/linux-x86/flex/
  2. mkdir flex-2.5.39.source
  3. tar -zxvf flex-2.5.39.tar.gz -C flex-2.5.39.source/
  4. cd flex-2.5.39.source
  5. mkdir install
  6. cd flex-2.5.39.source/flex-2.5.39/
  7. ./configure –prefix=/home/lxg/code/project/rk3399_one/rk3399_android_7.1/prebuilts/misc/linux-x86/flex/install
  8. make
  9. make install
  10. 将install/bin下flex 可执行文件替换掉AOSP/prebuilts/misc/linux-x86/flex下的flex-2.5.39可执行文件重新编译即可

问题 7


FAILED: /bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar  2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar 4.8.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-2.28.RELEASE.jar 2.28.RELEASE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-3.36.CANDIDATE.jar 3.36.CANDIDATE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.7.BETA.jar 4.7.BETA || exit 47 )"

解决方法

sudo vi /etc/java-8-openjdk/security/java.security


# jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \
jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, \
    DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
    include jdk.disabled.namedCurves

  1. cd prebuilts/sdk/tools/
  2. ./jack-admin kill-server
  3. ./jack-admin start-server

问题 8


device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
device/softwinner/common/vendorsetup.sh: 行 109: gawk:未找到命令
flags:WARN getopt:选项 ‘--platform_version’ 需要一个参数
 -i '-c' -p 'android' -b '-d' -s 'none' -v 'none' -- 'uart0'
flags:FATAL unable to parse provided options with getopt.
pack image failed!

解决方法

sudo apt install python