[dx] Could not reserve enough space for object heap

PHPからAndroidのapkをantでビルドする環境を作成中、ヒープ不足でVMが起動しない問題に遭遇しました。

-dex:
      [dex] input: /path1/to/bin/classes
      [dex] input: /path2/to/bin/classes.jar
      [dex] input: /path/to/android-sdk-linux/tools/support/annotations.jar
      [dex] input: /path2/to/libs/android-support-v4.jar
      [dex] Pre-Dexing /path2/to/bin/classes.jar -> classes-df6cdfb7c6be3c83700a640e18a54033.jar
       [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.

解決策は android-sdk-linux/platform-tools/dx の
defaultMx=”-Xmx1024M”
を小さくすればOKです。

今回は
defaultMx=”-Xmx128M”
としました。

dxコマンドを直接実行する場合は、コマンドに
-JXmx128M
とオプションを付ければ大丈夫なようですが、antの場合はできないっぽいです。

あと、ANT_OPTSはantの中で実行されるjavaコマンドについては引き継がないようです。


タグ: ,

新しく会社作りました!

コメントをどうぞ