'Android Studio freezes on indexing

my project was working well but suddenly when I ran it on my phone, Android Studio freezes and I should stop it from task manager. before this happens I installed "Geny motion" & "Virtual Box", but when the error occurred I uninstalled them. but the problem insisted.

android studio freezes on indexing

Solutions I've tried

  1. I uninstalled it and installed it again
  2. I unplugged and plugged in my device
  3. I disabled android indexing from setting

None of the above solutions worked.



Solution 1:[1]

Delete all Android Studio data - .gradle .android .androidstudio folders from your home folder. And all project build folders gradle and iml files.

Solution 2:[2]

This worked for me.

1.Close the project
2.Remove the project
3.Close Android Studio
4.Open it again
5.Open the project

Enjoy Coding!

Solution 3:[3]

Android Studio (3.1.3) froze on me while editing a source file. I waited and finally killed the process in Task Manager (Windows). Twice I tried to start up again and both times it got stuck with the "indexing..." message in the lower right. Both times I ended the process in Task Manager.

I looked in the source folder of the project I was working on. The source file I had been editing when it froze was "Receipt.java". There was another file in the src folder "Receipt.java__jb_tmp__". I deleted that file and Android Studio started up fine. It looks like I lost some edits, though.

When I did start up, it detected there had been some error and offered to submit a report.

Solution 4:[4]

I checked my java file and I saw somehow all the code in one of my java files was replaced with "NULL NULL NULL NULL....." I deleted the file and the application runs without a problem.

Solution 5:[5]

In my case color was declared as invalid, Android Studio ignored that and during building it froze. I had to remove the file, let it index, paste it back and fix the color string (it gave me error when I entered the pasted file)

Solution 6:[6]

just rename project folder then open IDE, it will show

enter image description here

now rename back to origin folder name, click open project

it work on my case

Solution 7:[7]

I have older project with sdk version 22, when I open it in android studio 3.1.2 on macOS. It keep indexing forever, everything was installed and configured properly but indexing loop never stopped.

Following worked for me

File > Invalidate caches/restart… > Invalidate caches/restart

Solution 8:[8]

Go to the File menu and click the option Invalidate Caches / Restart This will solve the problem ! Enjoy ;)

Solution 9:[9]

If the project is large & has a lot of modules, you might need to increase the Allocated Heap Size for Android Studio.

Go to Edit Custom VM Options from Help menu and increase the value for -Xms and -Xmx

This is what I'm using

-Xms2048m
-Xmx8192m
-XX:MaxPermSize=2048m
-XX:ReservedCodeCacheSize=1024m
-XX:+UseCompressedOops

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kreker
Solution 2 Braj Bhushan Singh
Solution 3 XtopherSD
Solution 4 Hadis
Solution 5 Janusz Hain
Solution 6 vuhung3990
Solution 7
Solution 8 Ali Yar Khan
Solution 9 flamyoad