Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Out of memory error while running gradlew assembleRelease - react-native

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:

  1. Added android:largeHeap="true" to the application tag in the AndroidManifest.xml

  2. Added

    dexOptions {     javaMaxHeapSize "4g"  } 

    in the android/app/build.gradle file.

  3. 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??

like image 323
FortuneCookie Avatar asked Dec 11 '19 11:12

FortuneCookie


People also ask

How do I fix expiring daemon because JVM heap space is exhausted?

This can be fixed by increasing the configured max heap size for the project. Through GUI: In the Settings, search for 'Memory Settings' and increase the IDE max heap size and Daemon max heap size as per the system RAM availability.

What went wrong Java heap space react native?

To fix Java Heap Space error in react native project, just add the heap size you wish to the app/build. gradle file. Here I've specified the Heap size to be 4gb. This solution could also fix JVM Heap Space is exhausted error.

How do I fix out of memory error in Android Studio?

If you haven't yet encountered an OOM in your Android application, you will in the near future. Memory leaks cause the OutOfMemoryError in Android. To eliminate the OutOfMemoryError, you must first eliminate memory leaks from your Android application. The Error!

How do I fix out of memory heap space in Java?

OutOfMemoryError: Java heap space. 1) An easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.


1 Answers

configuring gradle.properties:

org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureondemand=true 
like image 180
Aurangzaib Rana Avatar answered Sep 22 '22 14:09

Aurangzaib Rana