简体   繁体   English

在Ubuntu 15.10上构建android源代码时增加堆大小

[英]Increasing heap size while building the android source code on Ubuntu 15.10

I am trying to build the android source code in ubuntu 15.10, but I got an error. 我试图在ubuntu 15.10中构建android源代码,但是我收到了一个错误。 Now I want your help to build the android source code. 现在我希望你的帮助来构建android源代码。

including ./tools/external/fat32lib/Android.mk ...
Starting build with ninja
ninja: Entering directory `.'
[  0% 1/21542] Ensure Jack server is installed and started
Jack server already installed in "/home/smile/.jack-server"
Server is already running
[  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>'
Warning: This may have produced partial or corrupted output.
ninja: build stopped: subcommand failed.
build/core/ninja.mk:146: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1

#### make failed to build some targets (08:25 (mm:ss)) ####

Then I run "$ java -Xmx2048m" command and I get some lines: 然后我运行“$ java -Xmx2048m”命令,我得到一些代码:

 smile@smile:~/Android$ java -Xmx2048m
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32      use a 32-bit data model if available
    -d64      use a 64-bit data model if available
    -server   to select the "server" VM
    -zero     to select the "zero" VM
    -jamvm    to select the "jamvm" VM
    -avian    to select the "avian" VM
    -dcevm    to select the "dcevm" VM
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.

Who can help me how to increase heap size? 谁能帮我如何增加堆大小?

Your help will be greatly appretiated to me 你的帮助会非常适合我

Thanks in advance. 提前致谢。

smile@smile:~/Android$ java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-0ubuntu0.15.10.1)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

I've just run into same problem. 我遇到了同样的问题。

The problem is that virtual machine which runs jack doesn't have enough memory. 问题是运行插孔的虚拟机没有足够的内存。

You can try to edit jvm command: 您可以尝试编辑jvm命令:

JACK_VM_COMMAND=${JACK_VM_COMMAND:="java -Xmx4096m"}

or to decrease number of parallel jack compilations 或减少并行插孔编号的数量

SERVER_NB_COMPILE=2

in ~/.jack file. 〜/ .jack文件中。

You can read jack documentation for details. 您可以阅读杰克文档了解详细信息。

EDIT: Changing .jack file didn't work for me. 编辑:更改.jack文件对我不起作用。 After digging a little deeper I found that jack server is started with out/host/linux-x86/bin/jack-admin script and it's parameters can be passed with JACK_SERVER_VM_ARGUMENTS environment variable. 在深入挖掘后,我发现jack服务器是以/ host / linux-x86 / bin / jack-admin脚本启动的,它的参数可以通过JACK_SERVER_VM_ARGUMENTS环境变量传递。

So my solution was to set it and restart jack server before building aosp : 所以我的解决方案是在构建aosp之前设置它并重新启动jack服务器:

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

If you are building Android N then Jack config files is changed. 如果您正在构建Android N,则更改Jack配置文件。 apply above suggested configs by following Transition Guide. 按照过渡指南应用以上建议的配置。

find the config you want to change, find where it moved from $HOME/.jack and change it there. 找到你想要更改的配置,找到它从$HOME/.jack并在那里进行更改。

Transitioning from server 1.1 (eg Marshmallow) to server 1.3 (eg N) 从服务器1.1(例如Marshmallow)转换到服务器1.3(例如N)

The old Jack server used a $HOME/.jack configuration file. 旧的Jack服务器使用$HOME/.jack配置文件。 It has now replaced by a $HOME/.jack-settings and a $HOME/.jack-server/config.properties . 它现在已被$HOME/.jack-settings$HOME/.jack-server/config.properties取代。

If those new files do not exist, 如果这些新文件不存在,

run jack-admin start-server and they will be created. 运行jack-admin start-server ,它们将被创建。

If you had custom settings in your $HOME/.jack , here's how to adapt those. 如果您在$HOME/.jack有自定义设置,那么这里是如何调整它们的。

Step 1 步骤1

SERVER_PORT_SERVICE=XXXX Replace with SERVER_PORT_SERVICE=XXXX in $HOME/.jack-settings and jack.server.service.port=XXXX in $HOME/.jack-server/config.properties . SERVER_PORT_SERVICE=XXXX替换为$HOME/.jack-settings jack.server.service.port=XXXX $HOME/.jack-settings SERVER_PORT_SERVICE=XXXX$HOME/.jack-settings jack.server.service.port=XXXX $HOME/.jack-server/config.properties jack.server.service.port=XXXX

Step 2 第2步

SERVER_PORT_ADMIN=YYYY Replace with SERVER_PORT_ADMIN=YYYY in $HOME/.jack-settings and jack.server.admin.port=YYYY in $HOME/.jack-server/config.properties . SERVER_PORT_ADMIN=YYYY$HOME/.jack-settings jack.server.admin.port=YYYY $HOME/.jack-settings替换为SERVER_PORT_ADMIN=YYYY$HOME/.jack-settings jack.server.admin.port=YYYY $HOME/.jack-server/config.properties替换为jack.server.admin.port=YYYY

Step 3 第3步

SERVER_NB_COMPILE=N Replace with jack.server.max-service=N in $HOME/.jack-server/config.properties . SERVER_NB_COMPILE=N替换为$HOME/.jack-server/config.properties jack.server.max-service=N

Extra Settings 额外设置

SERVER_TIMEOUT=ZZ You can replace with jack.server.time-out=ZZ , but it is recommended to keep the default setting of “7200” (2 hours). SERVER_TIMEOUT=ZZ您可以使用jack.server.time-out=ZZ替换,但建议保留默认设置“7200”(2小时)。

Other settings in the $HOME/.jack configuration file do not need to be copied. $HOME/.jack配置文件中的其他设置不需要复制。 You should still keep your $HOME/.jack configuration file for the old Jack server because both server versions can run simultaneously. 您仍应保留旧的Jack服务器的$HOME/.jack配置文件,因为两个服务器版本可以同时运行。

Taken from Jack server , more on Compiling with Jack 摘自Jack服务器 ,更多关于使用Jack编译

jack_server_setup.mk under prebuilts\\sdk\\tools 在prebuilts \\ sdk \\ tools下的jack_server_setup.mk

ifneq ($(ANDROID_JACK_VM_ARGS),)
jack_vm_args := $(ANDROID_JACK_VM_ARGS)
else
jack_vm_args := -Dfile.encoding=UTF-8 -XX:+TieredCompilation
endif
.....
ifneq ($(dist_goal),)
    $(hide) mkdir -p "$(DIST_DIR)/logs/jack/"
    $(hide) JACK_SERVER_VM_ARGUMENTS="$(jack_vm_args) -Dcom.android.jack.server.log.file=$(abspath $(DIST_DIR))/logs/jack/jack-server-%u-%g.log" $(PRIVATE_JACK_ADMIN) start-server 2>&1 || exit 0
else
    $(hide) JACK_SERVER_VM_ARGUMENTS="$(jack_vm_args)" $(PRIVATE_JACK_ADMIN) start-server 2>&1 || exit 0
endif

So we can export 所以我们可以出口

ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"

to config jack args. 配置插孔args。 And then run this below: 然后运行以下内容:

./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server

goto build/core/config.mk and change heap size in 转到build / core / config.mk并更改堆大小

APICHECK_COMMAND := $(APICHECK) -JXmx8g -J"classpath $(APICHECK_CLASSPATH)" APICHECK_COMMAND:= $(APICHECK) -JXmx8g -J“classpath $(APICHECK_CLASSPATH)”

then it will work fine. 然后它会正常工作。
Other solutions didn't help me. 其他解决方案对我没有帮助。

Just try add 试试吧

export ANDROID_JACK_VM_ARGS="-Xmx8192m -Xms512m -Dfile.encoding=UTF-8 -XX:+TieredCompilation"

to the end of .bashrc and reboot Linux .bashrc结束并重启Linux

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM