Ubuntu 18.04 编译 AOSP 问题总结

2019-02-12  本文已影响31人  BlackJava
第一:安装正确的JDK

You asked for an OpenJDK based build but your version is
java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode).

注意:AOSP 编译需要使用 openjdk,不能使用oracle 的JDK 版本
解决办法:
1.查看java 安装情况

sudo update-alternatives --config java

2.卸载oracle java :

sudo apt-get purge oracle-java8-installer
  1. 安装open jdk: https://source.android.google.cn/setup/initializing.html
sudo apt-get update
sudo apt-get install openjdk-8-jdk    
第二:去除所有本地化的设置

error:flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed. Aborted (core dumped)

或者

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: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)

解决方法 : 在编译脚本中执行

export LC_ALL=C

LC_ALL=C 是为了去除所有本地化的设置,让命令能正确执行, 但是不可以修改~/.bashrc,会导致终端内中文显示为数字(应该是对应的编码)

第三:jack-server 未启动

No Jack server running. Try 'jack-admin start-server'
No Jack server running. Try 'jack-admin start-server'

解决办法:

out/host/linux-x86/bin/jack-admin start-server
第四:Jack server failed to start

[6% 1127/18030] Ensure Jack server is installed and started
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

No Jack server running. Try 'jack-admin start-server'
No Jack server running. Try 'jack-admin start-server'

bule@sky:~/**/jianwen.fu/V65_An7/prebuilts/sdk/tools$ jack-admin start-server
Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/prayasm/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
Jack server failed to (re)start, try 'jack-diagnose' or see Jack server log

解决办法:http://www.th7.cn/system/lin/201702/202334.shtml

 cd /prebuilts/sdk/tools/
 jack-admin start-server
 jack-admin kill-server
 jack-admin list-server
 jack-admin uninstall-server
 mm -j32 showcommands &> mm.out
 jack-admin install-server jack-launcher.jar  jack-server-4.8.ALPHA.jar
 jack-admin dump-report
 jack-admin dump-re
第五:Java heap 空间不足

[ 0% 2/21542] Building with Jack: out/target/common/obj/JAVA_LIBRARIES/core-all_intermediates/with-local/classes.dex
FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/core-all_intermediates/with-local/classes.dex.rsp
Java heap space
Try increasing heap size with java option '-Xmx<size>'

解决办法:

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
第六:库冲突

libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast

//依次输入以下命令(如果是在编译成功源码之后直接想运行模拟器,则直接输入emulator命令就行,因为前面编译源码已经输入过以上两条命令)

source build/envsetup.sh
lunch(选择刚才你编译源码设置的目标版本)
emulator -use-system-libs

或者

source build/envsetup.sh
lunch(选择刚才你编译源码设置的目标版本)
export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
emulator
上一篇下一篇

猜你喜欢

热点阅读