Unable to attach debugger in Android Studio - localhost:8600 java.net.ConnectException

前端 未结 11 2255
不思量自难忘°
不思量自难忘° 2021-02-07 00:35

I cannot attach the debugger in Android Studio while running debug on a phone.

I’m currently using a Samsung S4, running Android 4.4.4 (but have tried an S5, S6, S7, and

11条回答
  •  清歌不尽
    2021-02-07 01:22

    I have the opposite problem with Android Studio 3.3, trying to debug a wi-fi-connected phone.

    After selecting the device in Android Studio, I receive the following message:

    Error running 'app': Unable to open debugger port (localhost:8600): java.net.ConnectException "Connection refused: connect"

    I also have IPV-6 enabled on my network.

    The issue is that "localhost" resolves to ::1 on my machine by default, but ADB studiously binds explicitly to 127.0.0.1. I happen to know this because I spent the day trying to make ADB connect to emulators running on a remote machine (not since Android 4.4 unfortunately.

    To solve the problem, add the following line to \windows\system32\drivers\etc\hosts:

    127.0.0.1 localhost

提交回复
热议问题