Skip to content

Java Heap Space error in React Native – How to fix?

To fix Java Heap Space error in react native project, just add the heap size you wish to the app/build.gradle file.

android {
   .
	...
    dexOptions {
        javaMaxHeapSize "4g"
    }
  ....
}

Here I’ve specified the Heap size to be 4gb.

This solution could also fix JVM Heap Space is exhausted error.

Expiring Daemon because JVM heap space is exhausted
    
> Task :app:transformDexArchiveWithDexMergerForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForRelease'.
> java.lang.OutOfMemoryError (no error message)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.