13

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

noprops
  • 311
  • 3
  • 12

7 Answers7

12

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

kumamotone
  • 161
  • 2
  • 5
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).

Sjaak
  • 31
  • 3
  • 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. – Adam Howell Apr 20 '21 at 02:48
  • @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. – user1884325 May 08 '21 at 03:56
1

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

MarkT
  • 378
  • 2
  • 7
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

Ashley
  • 1
  • 1
0

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.

LXJ
  • 1,180
  • 6
  • 18
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.

James Poulose
  • 3,569
  • 2
  • 34
  • 39
0

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.

Khrisna
  • 1
  • 1