android7.0 源码编译问题总结

常见问题:

1.USER问题(由于运行的docker 容易没有配置USER环境变量)

      JACK VMCOMMAND="java -Dfile.encoding=UTF-8 -Xms2560m -XX:+TieredCompilation -jar out/host/linux-x86/framework/jack-launcher.jar " JACK_JAR="out/host/linux-x86/framework/jack.jar" out/host/linux-x86/bin/jack-admin start-server out/host/linux-x86/bin/jack-admin: line 27: USER: unbound variable

      这是由于docker没有设置USER环境变量导致,手动添加后继续编译即可

export USER=$(whoami)


    也可以在docker构建文件Dockerfile中加上如下语句:

ENV USER root   /////或者自己需要的名字


2.Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex

FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp
GC overhead limit exceeded
Try increasing heap size with java option '-Xmx'
Warning: This may have produced partial or corrupted output.
ninja: build stopped: subcommand failed.
make: *** [ninja_wrapper] Error 1

#### make failed to build some targets (14:09 (mm:ss)) ####

Same problem here.I tried setting JACK_SERVER_VM_ARGUMENTS to include -Xmx=4g, but when building again the log output showed that this was not included in the startup. Dunno why, seems like the env vars do not get passed to the build script correctly.

Solution: before starting a clean android build set the JACK_SERVER_VM_ARGUMENTS to include -Xmx=4g, then stop and start the jack servermanually. Given you're in the main source tree of AOSP run the following:

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

for cm you can use

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
jack-admin kill-server && jack-admin start-server

3.  如果编译的时候说jdk版本不对,要求1.8的就安装1.8的。而android7.0 要求的是OPNJDK1.8 不是oracle-jdk1.8.  如果是oracle的jdk1.8也没关系,只需要修改build/core/main.mk把里面的   requires_openjdk := false即可

# Check for the current JDK.
#
# For Java 1.7/1.8, we require OpenJDK on linux and Oracle JDK on Mac OS.
requires_openjdk := false
ifeq ($(BUILD_OS),linux)
requires_openjdk := false
endif




你可能感兴趣的:(android7.0 源码编译问题总结)