76

After updating the Android SDK, I started Android Studio. Now its showing background task continuously running with message

Updating indices: Scanning files to index.

In this mode, it is nearly hanged and I can not work on it. Not able to find a way to stop background task. A restart of Android Studio didn't work either.

Dhanuka
  • 2,826
  • 5
  • 27
  • 38
Paramvir Singh
  • 2,354
  • 1
  • 20
  • 20

10 Answers10

84

I've find out that I should use the solution of @free3dom which is the Invalidate Caches / Restart option in the File menu.

I have to do this every time I change some project file by switching branches in GIT.

And yes, Android Studio really sucks and is full of bugs...

Orabîg
  • 11,718
  • 6
  • 38
  • 58
30

Unplug all the phones and plug them again, it gets working. It is related to adb as stated here : https://code.google.com/p/android/issues/detail?id=172387 and a known bug that is to be fixed in the future

Buddy
  • 2,074
  • 1
  • 20
  • 30
3

The indexing is triggered through inotify on Linux.
There is a limit to how many directories a single user can set watches on. If your project is large, then this limit may be exceeded, and Android Studio falls back to recursive scanning mode, which is very slow.

To fix this, add this line to /etc/sysctl.conf file:

# Increase the limit for Android Studio
`fs.inotify.max_user_watches = 500000`

Then run sudo sysctl -p.

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
Sun
  • 41
  • 2
1

Stopping and closing the emulators that I had running solved this issue for me on the latest version of Android Studio.

sepulchre01
  • 1,068
  • 6
  • 6
0

I've this problem recently and in my case I'm using a linux 64bit SO and my android studio was in a ntfs disk. Since ntfs doesn't support executable permition the file fsnotifier64 was unable to execute and android-studio fallback into a compatibility mode that is much slower. The solution was copy the android-studio folder into my home folder that was ext4 and that way i was able to set permitions.

Pedro Rainho
  • 4,234
  • 1
  • 19
  • 21
0

I struggled with this issue for almost one hour, and after that found that this is the adb connection issue, you can disconnect your device once and stops all the working adb processes. This issue may get resolved.

Nisargi Joshi
  • 286
  • 3
  • 12
0

I'm also facing this issue, I've tried almost all the methods mentioned in this post, but none of them worked. The only solution that worked for me is to upgrade Android Studio to 3.5(which is still a test version at the time of writing this answer).

Searene
  • 25,920
  • 39
  • 129
  • 186
0

This happens to me after updating the Android Gradle plugin version from (3.5.3) to (3.6.2) and Gradle version from (5.4.1) to (5.6.4) it solved after downgrading the plugin again to change Android Gradle plugin version and Gradle version: File > Project Structure > Project File > Project Structure

Change it due to android studio reference

Update Gradle Reference

reference: https://developer.android.com/studio/releases/gradle-plugin.html

0

In my case, it was a module circular dependency problem. It wouldn't show until I removed all the changes into all build.gradle files, then reopen it and apply the stash.

It works :)

Rafael Ruiz Muñoz
  • 5,333
  • 6
  • 46
  • 92
-1

This was happening in my project every time I added a new Activity. So I included my R file in that class and it stopped.

eg: import com.domain.appname.R;

This fixed the problem.