'Out of memory error' when building Android on a VM

Viewed 3768

So, I'm trying to build Android. I select a device by lunch, make clean, and then run make updatepackage with various -j switches.

However, the build will fail with following error:

FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/core-all_intermediates/with-local/classes.dex.rsp
Out of memory error (version 1.2-a24 'Carnac' (283001 7e39a352cafc1eb3b4ae95846a101b93ccbc9cf0)).
Java heap space.
Try increasing heap size with java option '-Xmx<size>'.
Warning: This may have produced partial or corrupted output.
[ 42% 11683/27285] build out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/classes.jack
ninja: build stopped: subcommand failed.
build/core/ninja.mk:144: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1

The OS I'm using is Ubuntu 15.10 on a 4-core VM. I've tried adding more swap memory (currently it's 8GB and 24GB as swap), selecting various -j values (4 to 10), and as per GC overhead limit exceeded when building android source , changing -Xmx value.

As to the last one, the only reference to -Xmx is there:

APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)"

However, changing it to more from 1024m to anything else changes nothing.

So, what could I do to make it build?

0 Answers
Related