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

时间:2016-01-22 06:59:08

标签: java android ubuntu

我正在尝试在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)

5 个答案:

答案 0 :(得分:22)

我遇到了同样的问题。

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

您可以尝试编辑jvm命令:

/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:23: 
    RuntimeWarning: Parent module 'gtk' not found while handling absolute import
    import sys
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:30: 
    RuntimeWarning: Parent module 'gtk' not found while handling absolute import
    import gobject as _gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: 
    RuntimeWarning: Parent module 'gtk' not found while handling absolute import
    from gtk import _gtk

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

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

〜/ .jack 文件中。

您可以阅读jack documentation了解详情。

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

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

SERVER_NB_COMPILE=2

答案 1 :(得分:5)

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

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

从服务器1.1(例如Marshmallow)转换到服务器1.3(例如  N)

  

旧的Jack服务器使用$HOME/.jack配置文件。它现在有了   替换为$HOME/.jack-settings和a   $HOME/.jack-server/config.properties

如果这些新文件不存在,

  

运行jack-admin start-server并创建它们。

如果您在$HOME/.jack中有自定义设置,请按以下步骤进行调整。

第1步

  

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

第2步

  

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

第3步

  

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

额外设置

  

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

     

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

取自Jack server ,更多关于Compiling with Jack

答案 2 :(得分:5)

jack_server_setup.mk在prebuilts \ sdk \ tools

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

所以我们可以导出

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

配置千斤顶args。 然后运行以下内容:

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

答案 3 :(得分:2)

转到build / core / config.mk并在

中更改堆大小
  

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

然后它会正常工作。
其他解决方案对我没有帮助。

答案 4 :(得分:0)

试试添加

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

.bashrc 的末尾并重启Linux