VIISHRUT MAVANII
VIISHRUT MAVANII

Reputation: 12688

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!

Upvotes: 5

Views: 3902

Answers (4)

VIISHRUT MAVANII
VIISHRUT MAVANII

Reputation: 12688

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.

Upvotes: 1

Ahmad hassan zaki
Ahmad hassan zaki

Reputation: 1

Step 1 : Start Android studio and close any open project (File > Close Project).

Step 2 : On Welcome window, Go to Configure > Settings.

Step 3 : Go to Build, Execution, Deployment > Compiler

Step 4 : Change Build process heap size (Mbytes) to 512 and Additional build process to VM Options to -Xmx512m. Or any memory allocation in correspondent to your PC

Step 5 : Revalidate/Restart Android Studio.

Upvotes: 0

Martin Zeitler
Martin Zeitler

Reputation: 76699

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

Upvotes: 2

Prince Dholakiya
Prince Dholakiya

Reputation: 3401

Try this, It is working for me.

Replace below code to your gradle.properties file

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

Upvotes: 0

Related Questions