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.
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`
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.
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).
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
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.