Android Studio 错误:无法连接到守护进程 [英] Android Studio error: cannot connect to daemon

查看:127
本文介绍了Android Studio 错误:无法连接到守护进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 AS 几个月了,但是两天后我在尝试运行我的应用程序时出现错误:

I've been using AS for months, but since two days I get an error when I try to run my app:

Unable to run 'adb': null
'C:\Users\lapof\AppData\Local\Android\Sdk\platform-tools\adb.exe start-server' failed -- run manually if necessary
* daemon not running; starting now at tcp:5037
could not read ok from ADB Server
* failed to start daemon
error: cannot connect to daemon

我读过很多人遇到这个问题,但提供的解决方案对我不起作用.我特别阅读了这些问题:

I've read about a lot of people having this problem, but the solutions provided don't work for me. I read these questions in particular:

这些问题的很多答案都说要从任务管理器中关闭 adb.exe,问题是 adb.exe 没有运行,如果我尝试通过键入 .\adb start-server 在 PowerShell 窗口中,我收到相同的错误.

A lot of answers to these questions say to close adb.exe from task manager, the problem is that adb.exe is not running and if I try to restart it by typing .\adb start-server on a PowerShell window I get the same error.

我也尝试重新启动我的电脑,但没有成功.在我尝试连接到(三星 Galaxy S8)的 Android 设备上,我启用了 USB 调试.我什至试图消除所有授权设备,但没有任何效果.

I also try to restart my PC but it didn't work. On the Android device I'm trying to connect to (Samsung Galaxy S8) I enabled USB debugging. I even tried to eliminate all the authorized devices, but nothing worked.

我检查了 5037 端口是否被其他进程使用,但它被 adb.exe 使用(并且该端口上的防火墙状态是允许且不受限制的).顺便说一句,正如我所说,在任务管理器中 adb.exe 不存在.

I checked if the 5037 port was used by other processes, but it is used by adb.exe (and the firewall state on that port is allowed and not limited). By the way, as I said, in the task manager adb.exe is not present.

最后我尝试按照我链接的最后一个问题中提供的说明进行操作(基本上我重新下载了 adb.exe).最初我运行 .\adb start-server 并出现这个奇怪的错误:

Last I tried to follow the instructions provided in the last question I linked (basically I re-downloaded adb.exe). Initially I ran .\adb start-server and this strange error occurs:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *
** daemon still not running
error: cannot connect to daemon

然后当我尝试在 Android Studio 上运行我的应用程序时,它在尝试启动 adb 时会出现这个新错误:

and then when I try to run my app on Android Studio it occurs this new error when it tries to start adb:

Unable to run 'adb': null
'C:\Users\lapof\AppData\Local\Android\Sdk\platform-tools\adb.exe start-server' failed -- run manually if necessary
ADB server didn't ACK
* failed to start daemon *

然后如果我尝试 .\adb kill-server 然后 .\adb start-server.\adb devices.\adb usb 再次出现同样的错误.此外,当我现在连接我的设备时,它会要求我授权我的 PC 进行连接.

and then if I try to .\adb kill-server and then .\adb start-server or .\adb devices or .\adb usb the same error occurs again. Moreover when I connect my device now it asks me to authorize my PC to connect.

我不知道这是否有帮助,但最近我停用了很多 Windows 服务(但我认为我没有停用与 Android Studio 相关的某些东西).

I don't know if this can help, but lately I deactivated a lot of Windows services (but I don't think I deactivated something related to Android Studio).

  • PC:康柏
  • PC 操作系统:Windows 10 家庭版
  • 设备:三星 Galaxy S8 (Exynos)
  • 设备操作系统:Android 8.0
  • AS 版本:3.0.1
  • PC: Compaq
  • PC OS: Windows 10 Home
  • Device: Samsung Galaxy S8 (Exynos)
  • Device OS: Android 8.0
  • AS version: 3.0.1

推荐答案

我自己解决了这个问题.

I solved the problem on my own.

出于沮丧,我打开了控制面板>系统和安全 >Windows Defender 防火墙 >允许的应用程序,我添加了 adb.exe(私人和公共网络).

Out of frustration I opened Control Panel > System and security > Windows defender firewall > Allowed applications and I added adb.exe (both private and public networks).

我回到 Android Studio,运行该应用程序并神奇地设法初始化了 ADB,我通过 USB 连接的手机就在那里.

I came back to Android Studio, ran the app and magically it managed to initialize ADB and my phone connected via USB was there.

我真的不知道为什么会这样,因为当我签入 Start >所有程序 >配件 >系统工具资源监视器网络>侦听端口 它说在端口 5037 上允许防火墙.

I don't really know why this worked, since when I checked in Start > All Programs > Accessories > System Tools > Resource Monitor > Network > Listening Port it said that on port 5037 the firewall was allowed.

此外,我不知道为什么一周前一切正常,现在我必须执行此过程才能使其正常工作.

Moreover I don't know why up to a week ago all worked fine and now I had to do this process to make it work.

如果更有经验的人设法更好地解释这种行为,我会更新这个答案(或接受他的最佳答案)

If someone more experienced manages to explain this behaviour better I'll update this answer (or accepts his as best answer)

这篇关于Android Studio 错误:无法连接到守护进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆