21

I have been using Android Studio 2.1 for a while now, and in my previous projects, it seemed to work just fine. But now I got this error: enter image description here

This pestered me for a while until I decided to google solutions and ended up with some informative details like how to increase the heapsize and this seemed to work for the OP.

I haven't been successful yet.

I have twerked with the studio64.vmoptions file directly (even though A.S explicitly adviced otherwise, but i was desperate)

I noticed the problem occured a while later after intergrating Google Places API but i cannot establish the connection yet between the two.

Any suggestions? I could really use some help, my backlogged work is pilling up :(

This is how my vmoptions looks like:

# custom Android Studio VM options

#
# *DO NOT* modify this file directly. If there is a value that you would like to override,
# please add it to your user specific configuration file.
#
# See http://tools.android.com/tech-docs/configuration
#
-Xms512m
-Xmx2048m
-XX:MaxPermSize=512m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-da
-Djna.nosys=true
-Djna.boot.library.path=

-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-Dawt.useSystemAAFontSettings=lcd

Just additional info: I am on a Linux OS.

Raja Jawahar
  • 6,742
  • 9
  • 45
  • 56
Steve Kamau
  • 2,755
  • 10
  • 42
  • 73
  • 1
    check my answer [here](http://stackoverflow.com/questions/36861943/any-solution-for-android-studio-slow-gradle-build-and-high-disk-usage/36862637#36862637) and see if it helps – Atiq May 01 '16 at 09:29
  • i have checked it out, implemented your suggestions, now im waitig to see how it works out. – Steve Kamau May 01 '16 at 09:41
  • Something to note though, i have a ram of 5788 and about 1511 free. I had allocated Xms512m -Xmx2048m, and yur suggestions, advices lower. What are your thoughts? Isn,t the higher the values, the higher the performance? – Steve Kamau May 01 '16 at 09:46
  • well it doesn't the case always because studio doesn't use this much of ram always, and those settings a perfect fit and working so fine for me for all versions, just try them out if they works for you too that is why i included them as a comment not a answer :) – Atiq May 01 '16 at 09:49
  • I really appreciate how informative your answer is on the link. Let me give it a couple of mnutes and see how it works out. – Steve Kamau May 01 '16 at 09:52
  • Well nothing has happened yet which means that it's working efficiently! Let me upvote your answer o the link, really helpful! – Steve Kamau May 01 '16 at 17:06
  • thanks man, Glad I could help :) – Atiq May 01 '16 at 17:12
  • https://stackoverflow.com/questions/18723755/android-studio-how-to-increase-allocated-heap-size – Toir Oct 27 '18 at 08:09

5 Answers5

9

You can improve Gradle performance to avoid this message.

Create a file named gradle.properties in

/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)

and add the line:

org.gradle.daemon=true

This helps a lot, with org.gradle.daemon set to true Gradle reuses computations from previous builds and cache information about project structure, files, tasks etc. in memory so it won’t have to start up the entire Gradle application every time.

Anisuzzaman Babla
  • 6,510
  • 7
  • 36
  • 53
3

In my case, I was using Ubuntu 20.04, with 16GB of RAM which was mostly available, so this problem is clearly caused by something else other than lack of memory.

I solved it by closing the project and deleting the build and app/build directories within the project I was working on. On the next open I was able to code and build the app normally.

Alfonso
  • 76
  • 2
  • 4
1

I got same error while opening project. Below solution works for me.

Close Android Studio

Remove caches folder from C:\Users\USER_NAME\.AndroidStudio3.4\system

Reopen Android Studio and open or import project

Nik
  • 1,991
  • 2
  • 13
  • 30
1

i faced the same issue and i solved the problem by expanding emulator storage and sd card spaceemulator options

0

I solved the problem by updating Android Studio to the latest version.

enter image description here

IvanPavliuk
  • 1,460
  • 1
  • 21
  • 16