Try adding -Xmx512m
in Android Studio->Settings->Compiler->VM Options
as in below image.
Reason for this issue could be: Grade's build daemon ( forked process ) is invoked with maximum Java heap size as platform default value. On a 32 bit Windows this system this could be as high as 1GB. We get this error message, if that much(default) heap size cannot be allocated to the build deamon. So use the -Xmx
option to set a lower heap size. It is not necessary to stick to -Xmx<size>
with size as 512m
. In my Win 32bit, 4GB RAM machine, -Xmx768m
was also good enough.