Android Studio:无限期运行后台任务

时间:2022-02-11 00:20:42

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

更新Android SDK后,我启动了Android Studio。现在它显示后台任务持续运行消息

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.

在这种模式下,它几乎被绞死,我无法继续工作。无法找到停止后台任务的方法。重启Android Studio也无法正常工作。

5 个解决方案

#1


59  

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

我发现我应该使用@ free3dom的解决方案,它是文件菜单中的Invalidate Caches / Restart选项。

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

每次通过在GIT中切换分支来更改某个项目文件时,我都必须这样做。

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

是的,Android Studio真的很糟糕,而且充满了bug ...

#2


24  

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

拔下所有电话并重新插上电话,它就能正常工作。它与adb相关,如下所述:https://code.google.com/p/android/issues/detail?id = 172387以及将来要修复的已知错误

#3


2  

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.

索引是通过Linux上的inotify触发的。单个用户可以设置监视的目录数量有限制。如果您的项目很大,则可能会超出此限制,并且Android Studio会回退到递归扫描模式,这种模式非常慢。

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

要解决此问题,请将此行添加到/etc/sysctl.conf文件中:

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

Then run sudo sysctl -p.

然后运行sudo sysctl -p。

#4


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.

我最近遇到了这个问题,在我的情况下,我使用的是linux 64bit SO,我的android工作室是在ntfs磁盘中。由于ntfs不支持可执行的permition,文件fsnotifier64无法执行,android-studio回退到兼容模式慢得多。解决方案是将android-studio文件夹复制到我的主文件夹ext4,这样我就可以设置permitions。

#5


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.

我在这个问题上挣扎了将近一个小时,之后发现这是adb连接问题,您可以断开设备连接并停止所有正常工作的adb进程。此问题可能会得到解决。

#1


59  

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

我发现我应该使用@ free3dom的解决方案,它是文件菜单中的Invalidate Caches / Restart选项。

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

每次通过在GIT中切换分支来更改某个项目文件时,我都必须这样做。

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

是的,Android Studio真的很糟糕,而且充满了bug ...

#2


24  

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

拔下所有电话并重新插上电话,它就能正常工作。它与adb相关,如下所述:https://code.google.com/p/android/issues/detail?id = 172387以及将来要修复的已知错误

#3


2  

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.

索引是通过Linux上的inotify触发的。单个用户可以设置监视的目录数量有限制。如果您的项目很大,则可能会超出此限制,并且Android Studio会回退到递归扫描模式,这种模式非常慢。

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

要解决此问题,请将此行添加到/etc/sysctl.conf文件中:

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

Then run sudo sysctl -p.

然后运行sudo sysctl -p。

#4


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.

我最近遇到了这个问题,在我的情况下,我使用的是linux 64bit SO,我的android工作室是在ntfs磁盘中。由于ntfs不支持可执行的permition,文件fsnotifier64无法执行,android-studio回退到兼容模式慢得多。解决方案是将android-studio文件夹复制到我的主文件夹ext4,这样我就可以设置permitions。

#5


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.

我在这个问题上挣扎了将近一个小时,之后发现这是adb连接问题,您可以断开设备连接并停止所有正常工作的adb进程。此问题可能会得到解决。