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

raunit - in Android
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-picture
raunit

Technical Writer at CodingKaro

Share this on
Other Blogs in Android