How to fix adb.exe crash/restart loop in Android Studio

635 Views Asked by At

On a fresh install of Android Studio (Studio Build: 2022.3.1 Patch 2) on Windows 7, adb.exe gets run at startup. adb.exe 34.0.5 fails to start (crashes) the server then keeps retrying "forever" (looping the restart). Although Windows 7 is no longer supported by Android Studio, I have another Windows 7 machine where adb.exe 34.0.5 works fine. On the failing machine, the looping restart looks like this:

Adb connection Error:Connection reset
Cannot reach ADB server, attempting to reconnect.

* daemon not running; starting now at tcp:5037
could not read ok from ADB Server
* failed to start daemon
error: cannot connect to daemon
'C:\Users\Admin\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
'C:\Users\Admin\AppData\Local\Android\Sdk\platform-tools\adb.exe start-server' failed -- run manually if necessary

I closed Android Studio and in a command prompt (note: use your own location for where platform-tools is located), performed the following:

c:\> set ADB_TRACE=all
c:\> "C:\Users\Admin\AppData\Local\Android\Sdk\platform-tools\adb.exe" version
c:\> "C:\Users\Admin\AppData\Local\Android\Sdk\platform-tools\adb.exe" kill-server
c:\> "C:\Users\Admin\AppData\Local\Android\Sdk\platform-tools\adb.exe" server nodaemon

The server command crashed with adb.exe : sysdeps_win32.cpp:602 _socket_set_errno: mapping Windows error code 10061 to errno 22 The server did not keep running, as it was supposed to do.

Added the registry key:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\adb.exe]
"DumpFolder"=hex(2):43,00,3a,00,5c,00,43,00,72,00,61,00,73,00,68,00,44,00,75,00,6d,00,70,00,73,00,00,00

Which produced the following:

This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(6dc.1e2c): Unknown exception - code 40000015 (first/second chance not available)
eax=00000000 ebx=0045ee58 ecx=00000000 edx=00000000 esi=00000002 edi=00000000
eip=770d015d esp=0045ee08 ebp=0045eea4 iopl=0         nv up ei pl zr na pe nc 
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000246
ntdll!NtWaitForMultipleObjects+0x15:
770d015d 83c404          add     esp,4

This SO reference may be related to the above crash dump: https://stackoverflow.com/a/6079307

I tried upgrading "Universal C Runtime", as indicated here: https://support.microsoft.com/en-ca/help/2999226/update-for-universal-c-runtime-in-windows , but that did not change the symptoms.

How can adb.exe be made to run on this system without crashing?

2

There are 2 best solutions below

0
Dale On

Download the previous version of adb.exe from this location:

https://dl.google.com/android/repository/platform-tools_r34.0.4-windows.zip (note that a list of previous versions are available here: https://developer.android.com/tools/releases/platform-tools )

Save a back up of your platform-tools somewhere, then extract the contents of the earlier adb version to your platform-tools location.

Next time you start Android Studio, adb.exe should start without crashing.

The bug is closed because Windows 7 is unsupported: https://issuetracker.google.com/issues/308035747

0
AxeL On

The error message from adb reads "ddms: Unable to run 'adb': null. ddms: '/Users/Emre/Library/Android/sdk/platform-tools/adb,start-server' failed -- run manually if necessary." For a solution, there are two options: 1. Check port 5037, as in my case, Java was listening to this port. Close it with task manager to solve the problem. 2. Press ctrl+alt+delete if using Windows and start task manager. End all processes for adb.exe that you see in the processes tab.