Out of memory error: Java heap memory on Android Studio
I've finally solved it by limiting the Google Play service in gradle dependency.
The problem however was caused by the Google Play service, and by simply change it to a specific library, it is now solved.
com.google.android.gms:play-services-base:6.5.87
UPDATE
More info on android guides
Android Studio Build gradle OutOfMemoryError
One of the methods below should work for you:
METHOD 1 :
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
Depending on the Memory of your computer. Then
Invalidate Caches/Restart project from the File > Invalidate Caches/Restart
To clean up your gradle cache and implement your new heap size memory changes
METHOD 2 :
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.
METHOD 3 :
Go to your Android Studio Folder Where it is installed. There is File stduio.exe and studio64.exe with file type of VMOPTIONS, open it in notepad you will see Something like this:
-Xms512m
-Xmx1280m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=225m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Djna.nosys=true
-Djna.boot.library.path=
-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Didea.paths.selector=AndroidStudio1.3
-Didea.platform.prefix=AndroidStudio
Then change two values to suite you memory as below
-Xms512m
-Xmx1280m
OutOfMemoryError when compiling my android app with gradle
In my project there was a gradle.properties
file with these lines:
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
I uncommented the last line, and that worked.
Related Topics
Android SQLite and Huge Data Sets
Android Resource Not Found Exception
Getting Wrong Month When Using Simpledateformat.Parse
Android App Crashes After Sdk-Tools Update Version (Noclassdeffound, Tool Version 22)
Transparent Blurry View Which Blurs Layout Underneath
Custom Progress Bar in Android
Multiple Dex Files Define <My Package>/Buildconfig, Can't Find the Cause:
Android:Save a Bitmap to Bmp File Format
How to Get Java Output with Ruby
Converting a Java Arraylist of Strings to a JavaScript Array
Sending Message to Specific User on Spring Websocket
What Would an Ast (Abstract Syntax Tree) for an Object-Oriented Programming Language Look Like