Scanning files to index never ends in Android Studio 4.1
Asked Answered
F

8

14

I'm using cocos2d-x v4, macOS Catalina 10.15.6, Android Studio 4.1.

I made a project with cocos2d-x v4.

I'm using Android Studio to build an android app.

Until a few days ago it worked. But after updating Android Studio to 4.1, everything went wrong. When I open the project, it says Scanning files to index .. at the bottom of Android Studio and it never ends.

The Android tab on the left always says loading ..

enter image description here enter image description here

I tried the following, but none of them solved the problem.

  • Invalidate Caches / Restart
  • Uninstall and reinstall Android Studio
  • Reinstall an older version of Android Studio

When I uninstalled Android Studio, I ran the following command to remove all the old files.

rm -Rf /Applications/Android\Studio.app
rm -Rf ~ / Library / Preferences / AndroidStudio *
rm ~ / Library / Preferences / com.google.android.studio.plist
rm -Rf ~ / Library / Application \ Support / AndroidStudio *
rm -Rf ~ / Library / Logs / AndroidStudio *
rm -Rf ~ / Library / Caches / AndroidStudio *
rm -Rf ~ / .gradle
rm -Rf ~ / .android
rm -Rf ~ / Library / Android *

I spent a lot of time reinstalling Android Studio. I want to resolve this issue as soon as possible. Please let me know if there is a solution. Thank you.

enter image description here enter image description here enter image description here

Festschrift answered 17/10, 2020 at 10:28 Comment(0)
S
17

I have the same but I solved by removing .idea directory at root directory of the Android project.

Serge answered 23/2, 2021 at 12:49 Comment(0)
L
7

A very simple solution is delete all caches:

1 close Android Studio

2 go to:

C:\Users\ME\AppData\Local\Google\AndroidStudio2020.3 // or your current version

3 then click in "caches" directory

4 then delete all the cache files (There are two folders called project_resources and resources well DO NOT DELETE THESE FOLDERS)

5 Restart Android Studio

Loudmouthed answered 28/12, 2021 at 19:13 Comment(1)
Thanks. It worked on Android studio Hedgehog as well.Mingy
F
3

I have the same issue with a Cocos2d-X 3.17 project. Worked perfectly in 3.5 but with 4.1 it keeps on indexing. Force stopping and reopening leads to an eternal beachball.

By removing all .iml files and the .idea folders in the project and by invalidating all caches in Studio I got the project to load. Then I let it index all night (in Activity Monitor I could see that it was reading a lot of data... far more than the 15GB the project size is) without touching anything.

In the morning it actually was done indexing. However; Studio wanted to update some components and after that the index hell started again (using an imac pro with MacOS 10.15.7).

Update: Android Studio 4.1 seems to be indexing everything on the computer. It's now working on ~/Library/Containers/com.apple.iWork.keynote. Problem is that in there, there is a symbolic link to the drive which then results in recurring scanning and rescanning of folders. This also explains why the app wanted access to contacts, calendar and reminders....

Update 2: I have seemed to have solved it for now by excluding the application project folder from the index (right click on folder, select "mark directory as" and select excluded). For the folders to show you might have to delete the .idea and .gradle folders in the project before starting Studio).

Freitas answered 19/10, 2020 at 11:37 Comment(2)
4.2 RC1 on Windows seems to be indexing my entire mechanical 4-drive RAID drive. So it's still an issue. Also, I wouldn't have discovered this without your reply.Accustomed
@AdamHowell I can confirm the same for android-studio-ide-202.7322048-windows.exe. Android Studio starts indexing my entire fucking hard drive. Whoever let this slip through should be FIRED.Guadalupeguadeloupe
S
1

I just got this problem yesterday when I tried to open a project (relative small) fetched from github. On Ubuntu, with AS 4.1.3.

Initially, it was indexing for very long time. I did things like restarting AS, or deleting .ideas and .gradle, and etc, but in vain. Then I had to let it run. It finished indexing actually after quite long time.

Then I tried to refactor and migrate to Androidx, it ran endlessly by looking for this and that. I interrupted it a few times and tried the old tricks of deleting the folders and clearing cache, etc. No use. At one time, the refactoring process finished searching and prompted me to confirm refactoring. Then I found there were many files not in this project!

Then I went to check the project file structure (in the left pane where normally it's shown with Android structure), and I found the root directory of the project is my home directory (/home/leok) rather than the directory where the project files locate deep down from my home directory. So I suspected it was going through all of my files because of this. But why was it like this, I wondered.

Then I checked through build.gradle file. It turns out there was a reference to a directory like "/Data/xxxx/yyyy/etc" (I don't understand why the original author set it up this way, but I guess it's for building some intermediate data). I actually didn't have that directory on my machine, and strangely, AS or gradle somehow managed to work up from the root of the file system to my home directory where I guess it determined it can get write permission, a behavior very unscrupulous.

Then in build.gradle, I changed that reference to "Data/xxxx", which should point to a subdirectory under the project directory, and voila, problem solved. The indexing got normal, and the refactoring ran short.

So that's a lesson learned. It took most part of the day.

Spode answered 26/4, 2021 at 8:31 Comment(0)
L
1

You can "Invalidate Caches..." in Android Studio Toolbar.

Go to "File" -> Select "Invalidate Caches..." -> tick all the options and restart Android Studio.

Your Android Studio will try to re-builing all the caches and not stuck.

Lollis answered 2/8, 2023 at 5:46 Comment(0)
P
0

I have the same problem, first I tried changing inotify limits with no effect. I removed all the .idea directories, a small improvement but still unusable.

Solution was create a new user, with Android Studio and almost no other files

Postmeridian answered 6/3, 2021 at 17:3 Comment(0)
P
0

As a temporary solution I renamed the cache folder (to _cache) and was able to get away with this.

  1. Kill the studio from task manager.
  2. Rename folder to something else (I just didn't want to delete it).
  3. Start Studio again.

I will update here once I figure the actual reason.

Parclose answered 2/1, 2022 at 22:40 Comment(0)
T
0

I had the same problem when I "updated" to Android Studio Koala 2024.1.1 I have managed to fix this by going back to an earlier version of Android Studio. I tried several and ended up back at Dolphin, which does not have the problem - see version below.

To be clear: a major part of the problem is that studio incorrectly decides that it should index and symbol scan every C++ file on your entire drive. It does not handle large file numbers well, and so then runs out of memory, even if you give it Gigabytes. It will not allow later steps until indexing is complete, and won't allow disabling of indexing. This leaves studio unusable without giving it its own drive.

Android Studio Dolphin | 2021.3.1 Patch 1
Build #AI-213.7172.25.2113.9123335, built on September 30, 2022
Runtime version: 11.0.13+0-b1751.21-8125866 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

(I also had to fiddle with gradle and AGP to get it to work, back to versions Android Gradle Plugin: 7.3.1 Gradle 8.8)

Tournedos answered 10/7 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.