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
Although the given answer did not work for me, it did lead me to the correct path. Sometimes the build would go through but then again after some time this error would resurface, so to resolve it once and for all:
First comment org.gradle.jvmargs=-Xmx4096m
inside your project's gradle properties.
Add the following in your app/build.gradle:
android {
dexOptions {
javaMaxHeapSize "4g"
}
}
Now edit your global gradle.properties for mac it'll be inside Home/YOUR_USERNAME/.gradle/ Note that .gradle is a hidden folder.
If the file is not there simply create it and add
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
this worked for me!
uncommenting this line in android/gradle.properties
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
credit @Alex Aymkin
Adding this code in the android/gradle.properties worked for me!
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.