I am facing this issue while building my build.xml.
BUILD FAILED java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2786)
You need to set ANT_OPTS to next higher level in dx.bat file.which is located \build-tools\versions\dx.bat. set defaultXmx=-Xmx2048M I set it to 2GB.