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

2022-09-04 06:01:02

我试图在ubuntu 15.10中构建Android源代码,但我得到了一个错误。现在我需要你的帮助来构建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)) ####

然后我运行“$ 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.

谁可以帮助我如何增加堆大小?

您的帮助将大大地感谢我

提前致谢。

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)

答案 1

我刚刚遇到了同样的问题。

问题是运行插孔的虚拟机没有足够的内存。

您可以尝试编辑 jvm 命令:

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

或减少并行插孔编译的数量

SERVER_NB_COMPILE=2

~/.jack 文件中。

有关详细信息,您可以阅读插孔文档

编辑:更改.jack文件对我不起作用。在深入挖掘之后,我发现jack服务器是使用out/host/linux-x86/bin/jack-admin脚本启动的,它的参数可以用JACK_SERVER_VM_ARGUMENTS环境变量传递。

所以我的解决方案是在构建aosp之前设置它并重新启动插孔服务器:

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

答案 2

如果您正在构建Android N,则Jack配置文件已更改。按照过渡指南应用上述建议的配置。

找到您要更改的配置,找到它从哪里移出并在那里进行更改。$HOME/.jack

从服务器 1.1(例如 Marshmallow)过渡到服务器 1.3(例如 N)

旧的 Jack 服务器使用了配置文件。它现在已被 a 和 a 所取代。$HOME/.jack$HOME/.jack-settings$HOME/.jack-server/config.properties

如果这些新文件不存在,

运行,它们将被创建。jack-admin start-server

如果 中有自定义设置,下面介绍了如何调整这些设置。$HOME/.jack

步骤1

SERVER_PORT_SERVICE=XXXX替换为 in 和 in 。SERVER_PORT_SERVICE=XXXX$HOME/.jack-settingsjack.server.service.port=XXXX$HOME/.jack-server/config.properties

第 2 步

SERVER_PORT_ADMIN=YYYY替换为 in 和 in 。SERVER_PORT_ADMIN=YYYY$HOME/.jack-settingsjack.server.admin.port=YYYY$HOME/.jack-server/config.properties

第 3 步

SERVER_NB_COMPILE=N替换为 中的 。jack.server.max-service=N$HOME/.jack-server/config.properties

额外设置

SERVER_TIMEOUT=ZZ您可以替换为 ,但建议保留默认设置“7200”(2 小时)。jack.server.time-out=ZZ

配置文件中的其他设置不需要复制。您仍应保留旧 Jack 服务器的配置文件,因为两个服务器版本可以同时运行。$HOME/.jack$HOME/.jack

取自 Jack 服务器 ,有关使用 Jack 编译的更多信息