Android adb wireless debugging with USB accessory

2019-05-07 11:19发布

问题:

I have adb wireless connection working for debuging applications in eclipse, but I am having an issue with an application that is using the USB cable to attach to an accessory.

The application is designed to start when the accessory is plugged in, SO I establish my ADB connenction and then run debug on eclipse, code loads etc.., now when I plug the accessory in the app starts and runs but loses communication to eclipse. So I can't debug!

回答1:

In the command prompt just run adb connect <device ip>:5555 again after the tablet is plugged into the FT311 (I am assuming it is the FT311 from your other question). It will then reconnect and then run adb logcat again and done.



回答2:

That is only a partial solution. Yes, you can reestablish the connection over WiFi (which works great, BTW) but the moment you disconnect or reconnect the USB cable, you'll lose the association with ADB again - even though it's running over WiFi and should have no dependency upon USB at all.

So beware, this works but will not solve the problem if, for example, you're trying to debug anything associated with USB attach/detach Intents.



回答3:

USB host and accessory overview in Android official developer documentation here REMIND US OF THIS:

Debug considerations

When debugging applications that use USB accessory or host features, you most likely will have USB hardware connected to your Android-powered device. This will prevent you from having an adb connection to the Android-powered device via USB. You can still access adb over a network connection. To enable adb over a network connection:

  • Connect the Android-powered device via USB to your computer.
  • From your SDK platform-tools/ directory, enter adb tcpip 5555 at the command prompt.
  • Enter adb connect <device-ip-address>:5555 You should now be connected to the Android-powered device and can issue the usual adb commands like adb logcat.
  • To set your device to listen on USB, enter adb usb.

Remember:The Android official documentation will give you better basic understanding of the Android,not sometimes,but ALMOST everytime.