Table of contents

Android Studio build: Execution failed for task ':app:packageRelease'. java.lang.OutOfMemoryError

Android Oct 15, 2021 Viewed 1.2K Comments 0


To generate a signed Apk in Android Studio, I click Build -> Generate Signed Bundle / APK... . But there is an error when building.

Execution failed for task ':app:packageRelease'.
> A failure occurred while executing$IncrementalSplitterRunnable
   > java.lang.OutOfMemoryError (no error message)


Edit the file in the Android project, add or update the heap size of jvm argument:

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.

It can be 2g, if OutOfMemoryError still occurs, try 4g again, and so on.

Updated Oct 15, 2021