1

For an app I'm developing, I want to ease troubleshooting, both while it's in development and when it's released. I want to be able to retrieve calls to Log for when the app is being run without the phone connected in USB debugging, so it can be retrieved and sent to me. For example, when the app crashes, or when Log.e(...) is called, the log history (Calls to Log.i(), Log.w()) can be sent to a server, or the user can send it to me manually.

How can/should this be done?

Also, should the technique vary depending on if the app is in development vs release? (I know from the android Log docs that Log.v(...) should not be compiled into release versions - is there a better way than commenting out all those calls?)

It might make sense to extend Log or roll my own, but the devil is in the details.

Jodes
  • 14,118
  • 26
  • 97
  • 156

2 Answers2

1

For retrieving crash logs there is a library ACRA. Acra will send crash reports to your server. Alternately, google play also has a crashes & ANR's tab in the developer console where user's submitted crash reports are stored. Google play console's crash report is very easy to use and provides additional information of the number of same crashes and the version of the app in which the crash happened.

Illegal Argument
  • 10,090
  • 2
  • 44
  • 61
1

In my app I have created LogWrapper class which, as one may expect, wraps Log calls. Inside every method I am checking BuildCondig.DEBUG flag to determine if I am in debug or release mode.

Additionally, my LogWrapper check which method was making call and add it to the meassge, this is normally not available using Log class directly.

If app is in DEBUG mode I am passing log calls to Log class, otherwise I am passing log calls to 3rd party library, Crashlytics in my case. There is more crash tools e.g. Hockeyapp is also recommended platform.

Damian Petla
  • 8,963
  • 5
  • 44
  • 47