简体   繁体   中英

adb connection by wifi getting killed when a new USB attached/detached

I develop on my tablet using android studio . The tablet is connected to the computer by wifi using

adb connect <ip_andress>:5555

My application contains listeners for USB devices attached/detached . But unfourtunately, when I connect/disconnect usb device to/from the tablet, the adb connection is getting killed , and I can no longer see the device under "adb devices".

It is not a adb-connection-by-wifi what gets killed. It is just that USB enumerations affect the sys.usb.* system properties which on many devices is causing restart of adbd regardless whether it's being used over USB or tcpip .

Do grep "stop adbd" /init*rc to see what I mean.

You could either comment out those stop adbd lines or just disconnect the USB cable before running your adb connect command.

I was never able to connect my cellphone with my computar through wi-fi.

I had already given up. I followed all the instructions and tips, and nothing worked.

Finally, I did what no one said to do.

I've connected the phone to the WiFi network provided by the cable modem itself and not to some (not all) additional networks that are included in the router.

At home I use one of these networks, because I use a Deco Tp-Link router , which propagates the signal to my entire house, but this network is NOT compatible with ADB . It does not identify it as belonging to the same network.

After this, I use the normal procedure described here .

a) Connect cellphone with a USB cable

b) Find the IP_Phone depends on system in the cell phone. Here I use Settings , About Phone , Status and IP address .

c) Run the following adb commands in Command Prompt (Windows) or Terminal (Linux), where IP_Phone is the IP above mentioned. Normally adb.exe is an executable stored in computer path. adb is already included in Android Studio package.

adb tcpip 5555
adb connect IP_Phone 

d) Now disconnect USB cable and it's ready. The cellphone model continues to appear in the status line in the top of Android Studio .

-/-

The best wifi is that defined in Cable Modem. It, unlike an any account defined in my router, answers to a ping command.

ping IP_Phone

在运行adb connect <*ip_address_of_your_phone*>之前断开 USB 电缆

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM