Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Out of memory: Java heap space. OR GC overhead limit exceeded when building release APK after Android studio 3.4 update

After upgrade of Android Studio 3.4 getting below error. Gradel plugin version is: 3.4.0

Out of memory: Java heap space. Please assign more memory to Gradle in the project's gradle.properties file. For example, the following line, in the gradle.properties file sets the maximum Java heap size to

1,024 MB: org.gradle.jvmargs=-Xmx1024m Read Gradle's

configuration guide Read about Java's heap size

OR

GC overhead limit exceeded

I have applied below solution but it doesn't work.

Option: 1

dexOptions {
   javaMaxHeapSize "4g"
}

Option: 2

org.gradle.configureondemand=false

Option: 3

Open gradle.properties file from your project tree add this line at the memory allocation line

org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m

or

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m

or

org.gradle.jvmargs=-XX\:MaxHeapSize\=1024m -Xmx1024m

Please help me to solve this issue. Thanks in Advance!

like image 255
VIISHRUT MAVANII Avatar asked May 06 '19 06:05

VIISHRUT MAVANII


2 Answers

1024M is not much for Gradle, for example:

# @see https://docs.gradle.org/current/userguide/build_environment.html
org.gradle.jvmargs=-Xmx5084M -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.configureondemand=true
org.gradle.parallel=true

try values alike -Xmx2048M or -Xmx4096M ...

like image 110
Martin Zeitler Avatar answered Nov 19 '22 23:11

Martin Zeitler


I don't know it is a valid answer or not.

I have downgraded my gradle plugin version 3.4.0 to 3.3.2

It's work perfectly.

like image 1
VIISHRUT MAVANII Avatar answered Nov 19 '22 23:11

VIISHRUT MAVANII