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

查看:503
本文介绍了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:

  • Daemon not running. Starting it now on port 5037
  • Android ADB - Daemon still not running
  • How to resolve the "ADB server didn't ACK" error?
  • Eclipse error "ADB server didn't ACK, failed to start daemon"
  • Adb won't start
  • How to resolve the "ADB server didn't ACK" error?
  • Daemon not running. starting it now on port 5037 * Cannot open 'nul': The system cannot find the file specified

对这些问题的很多回答都说要从任务管理器中关闭adb.exe,问题是adb.exe没有运行,并且如果我尝试通过在PowerShell窗口中键入.\adb start-server来重新启动它,则会得到相同的结果错误.

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.

我也尝试重新启动PC,但是它不起作用. 在我尝试连接的Android设备上(三星Galaxy S8),我启用了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使用了5037端口(并且该端口的防火墙状态是允许的,但不受限制).顺便说一句,正如我所说,在任务管理器中没有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 Home
  • 设备:三星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.

出于无奈,我打开了Control Panel > System and security > Windows defender firewall > Allowed applications,并添加了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 > All Programs > Accessories > System Tools > Resource Monitor > Network > Listening Port时,它说在端口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天全站免登陆