1.安装好文档中要求的软件包以后,此时编译会遇到报错,显示: error while loading shared libraries: libncurses5 … :no such file or directory
查了很多博客发现还需要安装其他软件,因尝试了多次多种方法,故以下记录下来的可能有重复的软件包:
sudo apt-get install clang
sudo apt-get install lib32bz2-1.0
sudo apt-get install lib32z1
sudo apt-get install lib32ncurses5
sudo apt-get install lib32stdc++6
sudo apt-get install libcurses5:i386
sudo apt-get install cmake
sudo apt-get install ninja-build
sudo apt-get install cmake-doc
cd && sudo apt-get update && sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3.5 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib
sudo aptitude install lib32ncurses5-dev
(需要将ncurses降级到5.9,6.2不可用)
2.此时上述包该安装的都安装完了,编译仍会显示相同的报错,但在/usr/下使用find -name "*libncurses*"搜索包含该字符串的文件,可以看到有两个,一个是libncurses.so.5,另一个是libncurses.so.5.9。说明文件已存在但编译器检测不到。
先是将上述两个文件cp到/usr/local/lib,再在/etc/ld.so.conf.d中确保/usr/lib和/usr/local/lib存在。然后ldconfig -v更新下,ldconfig会出现新报错。显示: /sbin/ldconfig.real:/usr/local/lib/libncurses.so.5不是符号链接。 此报错解决方法:
3.之后编译出现错误Aborted(core dumped)。 常见的有两种可能:
一种因为编译android4.0需要4GB的RAM或SWAP空间,而ubuntu默认的1GB的,故而增加swap空间即可,借鉴的博客地址忘记了:
sudo dd if=/dev/zero of=/boot/swapfile bs=1024 count=4194304
sudo mkswap -v1 /boot/swapfile
sudo swapon /boot/swapfile
free
sudo vi /etc/fstab
在文件末尾加入/boot/swapfile swap swap defaults 1 1
另一种则可能是需要去除本地化设置。我遇到了这种错误,报错信息:flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertioncnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed. Aborted (core dumped) 则见https://www.52pojie.cn/thread-962233-1-1.html
4.此时编译,出现了新的报错:
[ 77% 58987/76471] Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex
FAILED: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex
/bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp
Out of memory error (version 1.3-rc7 'Douarn' (445000 d7be3910514558d6715ce455ce0861ae2f56925a by android-jack-team@google.com)).
GC overhead limit exceeded.
Try increasing heap size with java option '-Xmx<size>'.
Warning: This may have produced partial or corrupted output.
[ 77% 58990/76471] //art/compiler:libart-compiler clang++ optimizing/code_generator.cc [linux x86]
ninja: build stopped: subcommand failed.
17:43:41 ninja failed with: exit status 1
解决方法:https://www.52pojie.cn/thread-962233-1-1.html
5.至此编译成功,第一次编译成功花费了两天:)
6.后续编译,出现报错:
[ 74% 61328/82825] Building with Jack:...k_intermediates/with-local/classes.dexFAILED:
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex /bin/bash
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rspOut of memory error (version 1.3-rc7 'Douarn' (445000 d7be3910514558d6715ce455ce0861ae2f56925a by android-jack-team@google.com)).GC overhead limit exceeded.Try increasing heap size with java option '-Xmx<size>'.
Warning: This may have produced partial or corrupted output.
这是由于电脑内存不足引起的
输入以下三行即可: export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g" ./prebuilts/sdk/tools/jack-admin kill-server./prebuilts/sdk/tools/jack-admin start-server
补充:在远端服务器上编译同版本安卓后出现了新报错: Communication error with Jack server 1. Try ‘jack-diagnose’ 解决方法https://www.jianshu.com/p/764ed1d018aehttps://blog.csdn.net/czy_1125/article/details/78432018
PS:此后安卓系统跑起来后,串口一直输出: fusb302 4-0022:connection has disconnected 但没有usb设备断开,查找后,根据以下两个博客得出解决方法:http://www.thanksview.com/index.php/thread/19.mhtmlhttps://wiki.friendlyarm.com/wiki/index.php/SPI/zh 方法总结: 找到/rk3399-android-8.1/kernel/arch/arm64/boot/dts/rockchip/rk3399-nanopi4-common.dtsi(不同平台dtsi名称不同,nanopi m4是此文件),打开该文件,按照第一个链接thanksview中列出的数据结构修改。之后,工程目录下使用./build-nanopc-t4.sh重新生成img文件即可。