Liron Sher
Liron Sher

Reputation: 241

React-native 0.60 - Android build release failed - OutOfMemory

After upgrading to RN 0.60 - try to run the command:

react-native run-android --variant=release

Failed with error:

Execution failed for task ':app:packageRelease'. 2 exceptions were raised by workers: java.io.UncheckedIOException: java.io.IOException: Execution of compression failed. java.lang.OutOfMemoryError

The solution for me was:

  1. Adding dexoptions in app build.gradle
android {
    dexOptions {
        javaMaxHeapSize "4g"
    } 
}
  1. Increasing JVM heap size in gradle.properties
org.gradle.jvmargs=-Xmx4608M

Upvotes: 22

Views: 5856

Answers (3)

Lakshan Mamalgaha
Lakshan Mamalgaha

Reputation: 333

The way I solved this issue was

  1. In your ~android/app/build.gradle file add the following line
 android {
     ...
     dexOptions {
        javaMaxHeapSize "4g"
     }
     ...
     }
  1. In your ~android/gradle.properties add the following line
org.gradle.jvmargs=-Xmx4608m

Upvotes: 3

Shehzad Osama
Shehzad Osama

Reputation: 1302

This solution worked for me.

  1. Adding following in android/app/build.gradle:
android {
    ...
    dexOptions { javaMaxHeapSize "2g" }
    ...
    }
  1. Adding following in android/gradle.properties:

org.gradle.jvmargs=-Xmx4608M

Upvotes: 9

hong developer
hong developer

Reputation: 13906

Add android:largeHeap="true" to the application portion of the manifest.

Don't forget to recycle() once you've used Bitmap.

Upvotes: 1

Related Questions