1

I want to be able to access logcat for an app running on an Android TV device, but the TV only has a USB plug not micro-USB.

The Android TV device is

  • Running a custom Android 4.2.1 ROM (from manufacturer)
  • Doesn't provide access to device settings
  • Only has USB plugs
  • Environment#getStorageState() is always MEDIA_REMOVED

How can I get access to the application log?

William
  • 20,150
  • 8
  • 49
  • 91
  • Have you tried debugging via Android Debugging Bridge (ADB)? https://developers.google.com/tv/android/docs/gtv_debug – nKn Mar 04 '14 at 15:15
  • 1
    How do you suggest I connect my laptop to the TV? A male to male USB plug will not work. I'd love to use ADB, if I could get it connected. – William Mar 04 '14 at 22:16
  • What does "will not work" mean? Doesn't it detect the device, or it detects it you're unable to work...? By the way, it's possible you'd need to find the correct drivers for your laptop in order to handle correctly your TV. – nKn Mar 05 '14 at 15:40
  • Doesn't detect device. It's possible that it's just a matter of finding correct drivers, but I haven't found any that find the TV so far. I suspect it isn't working because both devices (laptop and TV) are trying to be the USB host. – William Mar 06 '14 at 01:41
  • You can connect ADB to your Google TV with IP if you have an access to device settings. Why doesn't your Android TV have access to device settings? – sam Mar 07 '14 at 00:33
  • The custom ROM that the manufacturer has applied locks down the device. So no access to device settings. – William Mar 07 '14 at 07:08

2 Answers2

2

You refer to

access logcat for an app

If "an app" is one that you are developing, then although Android now restricts installed apps from seeing the global logcat output, it still allows you to access data that your own process sends to logcat (whether from your own code, or from framework code that runs within your process). It's a simple matter of getting your app to run the logcat command on the device to send the data to a file, and then uploading that file to a webserver somewhere so you can read it.

(Read logcat programmatically within application gives the general principle, which is to exec the logcat program, and then read its output).

If however you are trying to get the logcat output from all the apps on the device, then getting adb working in some form is your only viable choice.

I assume you can install apps on the device, by placing them on an external website and downloading them using the device's webbrowser, then opening the downloaded file.

Thus you may be able to install a settings app extracted from a 4.2 phone, which might allow you to turn on adb debugging (though as you point out, the physical cabling is unusual).

Community
  • 1
  • 1
zmarties
  • 4,809
  • 22
  • 39
  • Yes, the app is my own. I am already a long way down the path of programatically extracting logcat and pushing it to a server. I guess I was looking for a generic solution since this is likely to be the first of many such devices and apps. I'll try the Settings app concept, but I think the cabling is likely to scupper a direct adb connection. – William Mar 06 '14 at 01:40
  • While I have listed my own solution above which is a superset, I'm giving you the bounty since it was good to get validation of the path I had already undertaken. – William Mar 10 '14 at 23:11
1

For those facing a similar issue, the solution I have chosen is as follows:

  1. Created a replacement for Android log that decorates Android log but also logs to a log4j RollingFileAppender. This was necessary because the circular logcat buffer on some of the devices was so small that it only contains 5 minutes of log.
  2. Added a menu action that posted all the log4j log files to a web server
  3. Added a Servlet to my web server to capture client log files and write them somewhere meaningful.

This seems to work reasonably well.

Aside from item 1 it is pretty the same as zmarties suggestion.

William
  • 20,150
  • 8
  • 49
  • 91