android应用构建: Could not reserve enough space for object heap

524 查看

windows下在命令行打包android程序,ant debug出错。

-dex:
      [dex] input: E:\jollywing\projects\my-tomatoes\bin\classes
      [dex] Converting compiled files and external libraries into E:\jollywing\p
rojects\my-tomatoes\bin\classes.dex...
       [dx] Error occurred during initialization of VM
       [dx] Could not reserve enough space for object heap
       [dx] Error: Could not create the Java Virtual Machine.
       [dx] Error: A fatal exception has occurred. Program will exit.

修改 dx.bat,位置在sdk目录下的 build-tools\android-4.3,找到

set defaultXmx=-Xmx1024M

改为

set defaultXmx=-Xmx512M

重新 ant debug 就可以重新构建了。