I am developing an application where my android phone connects to a USB accessory. However, when the accessory is connected is there any easy way to debug the application?
Can we use a micro usb hub or similar device?
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:
source: Android developer site
You could write an app that reads the logcat output on the phone and displays it on the screen and/or saves it to a file which you can pull with adb afterwards.
The app must be given READ_LOGS permission, which you can do with adb shell pm grant com.package.appname android.permission.READ_LOGS
(at least on a rooted phone).
Another alternative might be to log over WiFi. adb has an option to connect over TCP/IP, but this is not something I've tried so I don't know how difficult it is to set up or how well it works.
Unless your logs are really verbose it's sometimes enough to run through your USB accessory use-case and then unplug the accessory and connect the phone to your computer to catch the logcat output. The logs are buffered up to a certain amount, so you can get a reasonable amount of logs using this method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With