Android host mode USB debugging

I am developing an application in which my Android phone is connected to a USB accessory. However, when the accessory is connected, is there an easy way to debug the application?

Can i use a micro usb hub or similar device?

+8
android usb
source share
3 answers

When debugging applications that use the functions of a USB accessory or host, you will most likely have USB equipment connected to your Android device. This will not allow you to connect adb to your Android device via USB. You can still access adb over a network connection. To enable adb through a network connection:

  • Connect your Android device via USB to your computer.
  • In your platform-tools / SDK directory, enter the adb tcpip 5555 command line command at a command prompt.
  • Type adb connect <device-ip-address>: 5555 You should now be connected to an Android device and you can issue the usual adb commands, such as adb logcat.
  • To configure the device to listen via USB, enter usb usb.

source: Android developer site

+12
source share

You can write an application that reads the logcat output on the phone and displays it on the screen and / or saves it to a file that you can pull using adb. The application must be granted READ_LOGS permission, which you can do with adb shell pm grant com.package.appname android.permission.READ_LOGS (at least on the root phone).

Another alternative would be to register Wi-Fi. adb has the ability to connect via TCP / IP, but that’s not what I tried, so I don’t know how difficult it is to configure or how well it works.

If your magazines are not really detailed, sometimes just launching your USB accessory and then disconnecting the accessory and connecting the phone to the computer to catch the logarithm output. Logs are buffered to a certain size, so you can get a reasonable amount of logs using this method.

0
source share

You can run the Android image in Virtualbox. This will allow you to connect your USB device to a virtual device and debug through a bridged network connection.

I did not understand how to convert SDK.img OS images to VDI for use in Virtualbox, but there are many canned VDIs there.

0
source share

All Articles