0%

Android Studio调试器控制台显示Failed to connect port

❓ 我的Android Studio有问题。调试器控制台显示“Failed to connect”。任何Android设备(包括虚拟设备)中都会发生此问题。请给我一些想法来解决这个问题。

我试过了:

  • 重新启动Android Studio
  • 卸载Android Studio并重新安装
  • Clean Project
  • Rebuild Project
  • 刷新链接的C++项目
  • 重新安装LLDB,Android SDK平台工具和Android SDK工具

我的环境

1
2
3
Android Studio 3.5
All SDK Tools are latest version
OS:Windows10

在调试器控制台中:

1
2
3
4
5
6
7
8
9
10
11
12
09/12 15:38:17: Launching 'Unnamed' on Pixel XL API 28.
$ adb shell am start -n "com.yourcompany.prototype3/com.yourcompany.Prototype3" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.yourcompany.prototype3 | com.yourcompany.prototype3.test
Waiting for application to come online: com.yourcompany.prototype3 | com.yourcompany.prototype3.test
Connecting to com.yourcompany.prototype3
Now Launching Native Debug Session
$ adb shell cat /data/local/tmp/lldb-server | run-as com.yourcompany.prototype3 sh -c 'cat > /data/data/com.yourcompany.prototype3/lldb/bin/lldb-server && chmod 700 /data/data/com.yourcompany.prototype3/lldb/bin/lldb-server'
$ adb shell cat /data/local/tmp/start_lldb_server.sh | run-as com.yourcompany.prototype3 sh -c 'cat > /data/data/com.yourcompany.prototype3/lldb/bin/start_lldb_server.sh && chmod 700 /data/data/com.yourcompany.prototype3/lldb/bin/start_lldb_server.sh'
Starting LLDB server: /data/data/com.yourcompany.prototype3/lldb/bin/start_lldb_server.sh /data/data/com.yourcompany.prototype3/lldb unix-abstract /com.yourcompany.prototype3-0 platform-1568270301152.sock "lldb process:gdb-remote packets"
Failed to connect port

Process finished with exit code 0

在Logcat中:

1
2
3
4
2019-09-12 16:11:30.672 6551-6551/? I/pany.prototype: Not late-enabling -Xcheck:jni (already on)
2019-09-12 16:11:30.700 6551-6551/? W/pany.prototype: Unexpected CPU variant for X86 using defaults: x86
2019-09-12 16:11:30.905 6551-6551/com.yourcompany.prototype3 W/ActivityThread: Application com.yourcompany.prototype3 is waiting for the debugger on port 8100...
2019-09-12 16:11:30.907 6551-6551/com.yourcompany.prototype3 I/System.out: Sending WAIT chunk

✔️ 这是由Android SDK Platform-Tools 29.0.3损坏引起的

要解决此问题,您应该下载Platform-Tools 29.0.2。 替换Android SDK中的Platform-Tools。

UPD:此问题已通过Platform-Tools 29.0.4进行了修复:
https://issuetracker.google.com/140369526
现在,您可以更新到最新版本,而不是降级。