Android adb 无法启动守护进程,CreateProcess 失败,错误 2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26641496/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 12:00:25  来源:igfitidea点击:

adb cannot start daemon, CreateProcess failure, error 2

androidadb

提问by user2233706

I an unable to run adb rootor any adb command. I get the following error. I set ADB_TRACE=1:

我无法运行adb root或任何 adb 命令。我收到以下错误。我设置ADB_TRACE=1

C:\WINDOWS\system32>adb root
system/core/adb/adb.c::main():Handling commandline()
system/core/adb/adb_client.c::_adb_connect():_adb_connect: host:version
system/core/adb/sysdeps_win32.c::socket_loopback_client():socket_loopback_client: could not connect
to tcp:5037
system/core/adb/adb_client.c::adb_connect():adb_connect: service root:
* daemon not running. starting it now on port 5037 *
CreateProcess failure, error 2
* failed to start daemon *
error: cannot connect to daemon

I am using Windows 7.

我正在使用 Windows 7。

From netstat -aI don't see anything else using port 5037. When I run adb, I observe that adb momentarily is displayed on Task Manager, but then it goes away. Windows Firewall is turned off. I get the same results if I run cmdas administrator.

netstat -a我没有看到任何其他使用端口 5037 的东西。当我运行 adb 时,我观察到 adb 暂时显示在任务管理器上,但随后它消失了。Windows 防火墙已关闭。如果我cmd以管理员身份运行,我会得到相同的结果。

回答by Alex P.

You need to make sure that all your development tools use the same version of adb.

您需要确保所有开发工具都使用相同版本的adb.

One easy way to do that is to open the Command Promptwindow as Administrator and run these 2 commands to delete all copies:

一种简单的方法Command Prompt是以管理员身份打开窗口并运行以下 2 个命令以删除所有副本:

taskkill /f /im adb.exe
for %a in ("%systemroot%" "%userprofile%" "%path:;=";"%") do @del /q /f /s "%~a\adb.exe" "%~a\adbwinapi.dll" "%~a\adbwinusbapi.dll" 2>nul

Then reinstall the latest version of the platform-toolspackage from the SDK Manager or manually by downloading and unzipping the package file (check adbinfo pagefor the link) into the %ANDROID_SDK_HOME%folder.

然后platform-tools从 SDK 管理器重新安装最新版本的软件包,或者通过将软件包文件(查看链接的adb信息页面)下载并解压缩到文件夹中来手动重新安装软件包%ANDROID_SDK_HOME%

Also make sure that %ANDROID_SDK_HOME%\platform-toolsfolder is included in your %PATH%.

还要确保该%ANDROID_SDK_HOME%\platform-tools文件夹包含在您的%PATH%.

回答by user2233706

I solved this problem long ago, but did not update this question.

我很早就解决了这个问题,但没有更新这个问题。

I was having this issue because I was running the incorrect adb executable. I had one executable in C:\Windows\system32and another in a different directory. The version in C:\Windows\system32had did not have all the files needed by adb whereas the version in the other directory did. I'm not sure what those files were, but the adb executable was the same version in both directories. Since C:Windows\system32was in the PATH first, that version was executed first. I removed adb from the Windows directory, and the problem went away.

我遇到这个问题是因为我运行了不正确的 adb 可执行文件。我有一个可执行文件C:\Windows\system32,另一个在不同的目录中。C:\Windows\system32had 中的版本没有 adb 需要的所有文件,而另一个目录中的版本有。我不确定这些文件是什么,但 adb 可执行文件在两个目录中的版本相同。由于C:Windows\system32首先在 PATH 中,因此首先执行该版本。我从 Windows 目录中删除了 adb,问题就消失了。

回答by Dylan Breugne

I faced the same issue, to solve it, I have uninstalled the package Platform-tools on the SDK manager -> SDK tools and re-installed it. Now, It's working correctly.

我遇到了同样的问题,为了解决它,我卸载了 SDK 管理器上的 Platform-tools 包 -> SDK 工具并重新安装它。现在,它工作正常。

回答by onesam

I just solved this issue by going to Task Manager and killing all the adb' then it works like a charm.

我刚刚通过转到任务管理器并杀死所有 adb' 来解决这个问题,然后它就像一个魅力。

回答by Shawn Q

I solved this by going to the actual platform-tools directory.

我通过转到实际的平台工具目录解决了这个问题。

Default path is C:\Users[youruser]\AppData\Local\Android\sdk\platform-tools

默认路径为 C:\Users[youruser]\AppData\Local\Android\sdk\platform-tools

Apparently it won't start unless you change to that directory.

显然,除非您更改到该目录,否则它不会启动。

回答by user5527507

You can try this solution: Move the adb.exeand adbwinapi.dllto X:\Windows\system

您可以尝试此解决方案:将adb.exeadbwinapi.dll移动到X:\Windows\system

It worked for me

它对我有用

回答by fulllikeraisin

I got the same problem, BTW I am using win7 64bit.

我遇到了同样的问题,顺便说一句,我使用的是 64 位 win7。

solved it like this: Move the adb.exe and adbwinapi.dll to X:\Windows\SysWOW64

像这样解决它:将 adb.exe 和 adbwinapi.dll 移动到 X:\Windows\SysWOW64

hope useful

希望有用