Build ionic1 with typescript cause "Java heap space"


#1

I have ionic v1 project which I’m successfully compiling with gulp build, it runs ionic serve successfully and works in the browser.
But when I run ionic cordova build android, I wait about 10 minutes, the process runs, and then get the next error:

:processArmv7DebugJavaRes

UP-TO-DATE
:transformResourcesWithMergeJavaResForArmv7Debug

:validateSigningArmv7Debug
:packageArmv7Debug
Exception in thread "pool-41-thread-7" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:3236)
        at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
        at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
        at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
        at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253)
        at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211)
        at java.io.FilterOutputStream.write(FilterOutputStream.java:97)
        at com.android.builder.internal.packaging.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:70)
        at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:55)
        at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor$$Lambda$225/1736913926.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

Can anyone help me?