3

EDIT

With credit to F43nd1r, the solution is to put LOGCAT in your ReportsCrashes annotation, e.g.

@ReportsCrashes (
  mailTo = "log@perinote.com",
  mode = ReportingInteractionMode.TOAST,
  customReportContent = {ReportField.ANDROID_VERSION, 
                         ReportField.STACK_TRACE, 
                         ReportField.LOGCAT},
  resToastText = R.string.crash_toast_text
)

ORIGINAL POST

I'm trying out ACRA and would like it to capture the stack trace and logcat. At the moment, I have it configured to invoke my email app to send the data. Upon a crash, it is display a toast and is opening the email app with the stack trace in the message body. However, there is no logcat.

As best as I can tell according to the documentation, when I put the READ_LOGS permission in the manifest, it should include the last 200 lines of the logcat in the report.

I'm testing on an Android 7.0 device.

manifest:

<manifest package="com.perinote.crashtest"
          xmlns:android="http://schemas.android.com/apk/res/android">

  <uses-permission android:name="android.permission.READ_LOGS"></uses-permission>

  <application
    ...
  </application>
</manifest>

package com.perinote.crashtest;

import ...;

@ReportsCrashes (
  mailTo = "log@perinote.com",
  mode = ReportingInteractionMode.TOAST,
  resToastText = R.string.crash_toast_text
)

public class AppSubclass extends Application
{
  @Override
  protected void attachBaseContext(Context base)
  {
    super.attachBaseContext(base);
    ACRA.init (this);
  }
}

I don't think any other of my files are relevant, but let me know if you need more info.

Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
  • 1
    **Nitpick**: READ_LOGS is not used. you have to have the system signature to use it – Zoe Jun 16 '17 at 19:26

1 Answers1

3

Including a full report could be quite difficult due to the data size. Default fields included in email reports are:

  • ReportField.USER_COMMENT
  • ReportField.ANDROID_VERSION
  • ReportField.APP_VERSION_NAME
  • ReportField.BRAND
  • ReportField.PHONE_MODEL
  • ReportField.CUSTOM_DATA
  • ReportField.STACK_TRACE

Source: Sending Reports by Mail

So, if you want to include logcat, you have to modify the report fields to include ReportField.LOGCAT.


Note that starting from ACRA 4.9.3 (Unreleased) you'll be able to send the report as a mail attachment instead of as body, so size shouldn't be a problem anymore. Until then, including logcat might result in unsendable reports (as they might exceed character limits imposed by mail providers).


The above answer only applies to ACRA 4.x. In ACRA 5.x the default configuration is the same for all senders and does include logcat.

F43nd1r
  • 7,690
  • 3
  • 24
  • 62
  • My question states that *no* logcat was included in the email - attachment or in body. Do you have an answer for my question? Thanks. – Peri Hartman Jun 01 '17 at 13:43
  • That's because logcat is not in the default list - you have to include it. Edited answer for clarity. – F43nd1r Jun 01 '17 at 13:47
  • Thank you, thank you ! This works. Unfortunately, their documentation says only to include the READ_LOGS permission in the manifest. Even on the page you reference, there is no mention of ReportField.LOGCAT. – Peri Hartman Jun 01 '17 at 16:26