I am getting this error while making a release build for my react native project:
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)
Done some research and made some changes, which are below:
Added android:largeHeap="true"
to the application tag in the AndroidManifest.xml
Added
dexOptions {
javaMaxHeapSize "4g"
}
in the android/app/build.gradle file.
Added the below code to gradle.properties
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
Still I am not able to get rid of this error. Any permanent way to get rid of this error and how is it caused??
configuring gradle.properties:
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true