九鼎创展论坛

标题: Android编译错误之java.lang.OutOfMemoryError: Java heap space,解决方案 [打印本页]

作者: jjj    时间: 2013-2-27 13:13
标题: Android编译错误之java.lang.OutOfMemoryError: Java heap space,解决方案
在编译Android系统时,特别是Android4.0时,比较容易出现如下错误,解决方案如下:
方法一:
  1. diff --git a/android4.0/build/tools/releasetools/common.py b/android4.0/build/tools/releasetools/common.py
  2. index 4957354..aacb18c 100644
  3. --- a/android4.0/build/tools/releasetools/common.py
  4. +++ b/android4.0/build/tools/releasetools/common.py
  5. @@ -355,7 +355,7 @@ def SignFile(input_name, output_name, key, password, align=None,
  6.    else:
  7.      sign_name = output_name

  8. -  cmd = ["java", "-Xmx2048m", "-jar",
  9. +  cmd = ["java", "-Xmx256m", "-jar",
  10.             os.path.join(OPTIONS.search_path, "framework", "signapk.jar")]
  11.    if whole_file:
  12.      cmd.append("-w")
复制代码
如还异常,则尝试方法二:
  1. diff --git a/android4.0/build/core/definitions.mk b/android4.0/build/core/definitions.mk
  2. index 683ae16..3b3d6f9 100644
  3. --- a/android4.0/build/core/definitions.mk
  4. +++ b/android4.0/build/core/definitions.mk
  5. @@ -1525,7 +1525,7 @@ define transform-classes.jar-to-dex
  6. @echo "target Dex: $(PRIVATE_MODULE)"
  7. @mkdir -p $(dir $@)
  8. $(hide) $(DX) \
  9. -    $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx1536M) \
  10. +    $(if $(findstring windows,$(HOST_OS)),,-JXms1024M -JXmx2048M) \
  11.      --dex --output=$@ \
  12.      $(incremental_dex) \
  13.      $(if $(NO_OPTIMIZE_DX), \
复制代码





欢迎光临 九鼎创展论坛 (http://bbs.9tripod.com/) Powered by Discuz! X3.2