Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

android studio - On Windows, adb connects to wrong port 5037 instead of 5555

Debugging an Android App over WiFi. I am using WiFi ADB App to prepare the Android Device for the connection over Wifi. All seems well on that end.

Next, I need to connect adb as follows:

adb connect 192.168.2.8:5555

Sometimes this works properly. But more often, I get the following message:

C:> adb connect 192.168.2.8:5555
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
connected to 192.168.2.8:5555

Even though everything seems in order, I have learned that when I see this message, AndroidStudio (version 1.1.0) will not be able to find my AndroidDevice.

I am not the first to run into this, this article suggests a solution. This does not (or nearly never) work for me. However, interesting things do happen.

  • When opening up Windows TaskManager, I can see one adb.exe (32 bit) background process. I kill it via End task button.

  • Next, I execute the adb connect 192.168.2.8:5555 command in Windows cmd shell. I briefly see two adb.exe (32 bit) background processes appear in TaskManager. After a second, one process disappears.

  • In the cmd shell, I get the same stuff about starting on port 5037, which means that -again- AndroidStudio can not find my device.

It looks to me like two adb.exe processes are started up, that one locks port 5555, and that neither process give me a findable connection; not even after one of the processes has been (auto)terminated.

How can I connect adb so that it actually starts on port 5555 and AndroidStudio can actually find my device?

update:

1.) I misunderstood the message:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *

This means that the daemon is not yet running on the development machine. (I understood this to be the target machine.) You will get this message if you issue adb connect *.*.*.* without AndroidStudio running (yet). On the development machine, it stars on port 5037.

Then, you get the message:

* daemon started successfully *
connected to 192.168.2.8:5555

It means that it is connected to port 5555 on the target machine (= your Android device).

  1. It turned out, the above issue was caused by faulty hardware (WiFi adapter). So I was barking up the wrong tree; looking for a software solution.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

On Windows, in the console, the solutions appears to be (?)

adb kill-server
SET ANDROID_ADB_SERVER_PORT=5555
adb connect 192.168.2.8:5555

AndroidStudio finds the device after the extra adb tcpip 5555 statement.

update:

The above does not appear to be the solution, at least not in 100% of the cases. Still haven't found something that works and is reproducible...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...