Fixing java.lang.OutOfMemoryError: Java heap space | Android Studio Error

Raunit Verma - in Android
Views: 8

Learn how to fix the "java.lang.OutOfMemoryError: Java heap space" error in Android Studio. Follow our expert tips to improve your development efficiency.
Error Image
Error in Android Studio
One thing you can try is increasing the memory for the Android Studio process if your system has limited it.
Here is another thing that you should try out.
Android Studio Setting
Android Studio Setting
Open the Android Studio setting, try increasing the memory, and retry building the app. If the problem persists, see the video below and try the steps.
Go to gradle.properties, look for "org.gradle.jvmargs" and update the value. See the Example below. Previously it was
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
Change 2048 to 4096 or greater like below. It will be good if the number is multiple of 1024.
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
Now this should solve the issue. Watch the video for more. Thanks for reading this blog.
Tagsandroid studioout of memoryjava heap space
Raunit Verma-picture
Raunit Verma

Technical Writer at CodingKaro

Share this on
CodingKaro Poster
CodingKaro
4.7

3K+ Downloads

One of its unique features is an automated coding contest reminder, which sets alarms for upcoming coding contests on popular platforms like CodeChef, CodeForces, and LeetCode, without the need for user input. This feature ensures that users never miss a coding contest and can stay updated with the latest coding challenges.

Download CodingKaro
Other Blogs in Android