Summary of android7.0 source code compilation problems

Reprinted: https://blog.csdn.net/ronnyjiang/article/details/55812305

common problem:

1. USER problem (since the running docker is easy to not configure the USER environment variable)

      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

      This is because docker does not set the USER environment variable, you can continue to compile after adding it manually

[html]  view plain copy  
  1. export USER=$(whoami)  


    You can also add the following statement to the Docker build file Dockerfile:

[html]  view plain copy  
  1. ENV USER root ///// or the name you need  


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<size>'
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:

[html]  view plain copy  
  1. export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"  
  2. ./prebuilts/sdk/tools/jack-admin kill-server  
  3. ./prebuilts/sdk/tools/jack-admin start-server  

for cm you can use 

[html]  view plain copy  
  1. export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"  
  2. jack-admin kill-server && jack-admin start-server  

3. If the jdk version is wrong when compiling, install 1.8 if you require 1.8. And android7.0 requires OPNJDK1.8 not oracle-jdk1.8. It doesn't matter if it is oracle's jdk1.8, just need to modify build/core/main.mk to put requires_openjdk := false inside

[html]  view plain copy  
  1. # Check for the current JDK.  
  2. #  
  3. # For Java 1.7/1.8, we require OpenJDK on linux and Oracle JDK on Mac OS.  
  4. requires_openjdk :false  
  5. ifeq ($(BUILD_OS),linux)  
  6. requires_openjdk :false  
  7. endif  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324706054&siteId=291194637