Resolving problems with Android Studio freezing constantly
Asked Answered
H

7

32

I have 8GB of RAM and 500GB hard disk but when I am using Android Studio it still freezes so much that I am unable to do my work. I have reinstalled the software without any improvement. I also formatted my system and reinstalled Android Studio again but nothing works. Can anyone tell me what can be a possible solution to this?

Halfslip answered 17/8, 2016 at 4:38 Comment(16)
which processor your system have?Confine
which proccy? I think you need atleast i5 or equivalentOppilate
see this link you got idea about system recommendation for android studio developer.android.com/studio/…Confine
I am having i3 processor with 1.7 GHzHalfslip
1.7Ghz? using a laptop?Oppilate
yes I am using a laptop.From the last 2 days it is not working properly .Earlier it use to work properlyHalfslip
i do not think you can get more performance out of it, i myself use a 2.0ghz i3 with 12gb ram and still it lags,Oppilate
although there are few steps you can take to make it a little bit fasterOppilate
like what steps ???Halfslip
it used to work alright, but not since 2 days ago? what did you do to your comp 2 days ago? you may need to clean your comp from errors or malware.Oilstone
There are no malware or virus .Because my whole system is working properly .Only android studio is not workingHalfslip
1. "tools.android.com/tech-docs/configuration" change -Xmx4096m 2. disable vcs 3. disable instant run if you test on multiple devices 4. use dex in process medium.com/google-developers/… 5. last try invalidating studio cacheOppilate
In my case my custom view call itself, this infinity cycle lead to freezingWayfarer
This problem is still occurring in 2021 and needs to be resolved. It is happening to me on an i9-10990k with 32g RAM and M2 1TB SSD with lots of space. The whole IDE hangs when this occurs. If Android Studio was properly implemented, it would at MOST hang one thread, and not the entire IDE so that menus cannot be clicked/characters cannot be typed. Seems like a threading/deadlock/priority inversion issue in Android Studio. How do we go about reporting this properly so it is fixed once and for all? @user7856586, that should only hang your app, not the IDE if Android Studio worked as it shouldNunnery
@Nunnery Have you found a solution? Android Studio sometimes becomes unusable due to this issue on my PC with 48GB RAM and 1TB M2 SSD.Externalization
@Externalization yes and no. I mostly work in VSCode now and have given up on Android Studio unless I really need to use it. I try to avoid it since it is so unstable.Nunnery
T
8

In android studio application package content, edit studio.vmoptions file and increase "-Xms" and "-Xmx" parameters like

-Xms1024m
-Xmx4096m

UPDATE

I figured out that idea is getting error while writing or reading cache (from idea.log)

WARN - .caches.project.IdeaModuleInfo - Could not find correct module information. Reason: Analyzing element of type class com.android.tools.idea.databinding.LightGeneratedComponentClass with no containing file Text: null

Every time when android studio freezes, I delete .idea/caches/ in project folder so it fixes freeze problem temporary

Tramway answered 2/8, 2018 at 13:2 Comment(2)
Deleting the caches folder did it for me. Would be nice if code analysis didn't lock up 10 times a day.Door
Of course, deleting caches only works ONCE. Then code analysis simply freezes again in another 5 minutes, with nothing left to delete.Door
T
6

in my case, noticed that the number of "Recent hangs" of Android Studio was constantly increasing, and unplugged the USB cable which connected an Android phone for debugging did solve my problem.

Transience answered 19/3, 2019 at 6:10 Comment(0)
M
4

Clean the cache via this menu:

File -> Invalidate Caches/Restart

and then it should work properly.

Mummer answered 16/7, 2018 at 13:10 Comment(2)
@Meriam what is the problem exactly? What is your operation system? please tell the details.Mummer
this is what I did before th instance that crushedVarrian
M
2

This method worked for me after trying many other methods.

1. Update Android SDK tools and latest SDK platform.

2. Remove the Android Studio cache folder situated in C:\users\username\.AndroidStudioPreview2.0

3. Run Android Studio again.

Manville answered 17/8, 2016 at 4:44 Comment(0)
L
1

In my case I have been connecting my phone through a VERY long USB extension cable.

Reconnecting device with a short cable solved the issue.

Lariat answered 10/8, 2017 at 11:14 Comment(0)
L
1

I often switch on "Safe Mode". It disables Syntax check and Inspections, but reduces AS freezing while typing. click on man's pic in right bottom

Linson answered 6/8, 2018 at 7:33 Comment(0)
B
1

IMPORTANT

I notice after I completed the below steps everything worked fine. But after I did a git commit and changed the project folder name, Android Studio froze again. To fix the issue I had to do only step 2 all over again.

I had to do 3 steps (seperately):

  1. When Android Studio first opens, I selected Android Studio then Check for Updates

  2. When Android Studio first opens, I selected File > Invalidate Caches. In the Invalidate Caches popup tik both Clear file system cache and Local History and Clear VCS Log caches and indexes then select Invalidate and Restart

enter image description here

  1. To build on Enes answer to increase the size to 4096, when the Android Studio first opens, on the Welcome screen, select More Actions > SDK Manager. On the next screen, in the left panel, select Memory Settings and then on the right panel change the IDE Max heap size to 4096 MB then select OK at the bottom.

enter image description here

enter image description here

Bohol answered 15/10, 2022 at 16:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.