问题
So I'm using ACRA 4.4.0 with all defaults, and my logcat field is empty.
My app has the
<uses-permission android:name="android.permission.READ_LOGS" />
permissions, which should at least give me my own app logs since Jelly Bean.
Final note: READ_LOG permission is not granted to third-party apps anymore since Android 4.1 (JellyBean). Starting with this version, logcat provides only traces from your own app, without requiring a permission. JellyBean logcat logs are retrieved by ACRA starting with version 4.3.0b2
So I do a forced log:
Log.i("mytag" , "message");
ACRA.getErrorReporter().handleException(null);
On the emulator (v4.2), I get the full logcat. (Which BTW is somewhat contradictory to the JB imposed logcat restriction)
However, on my device v4.2.1, the logcat is completely empty.
Anyone has any ideas?
回答1:
If you are using email-mode acra reporting (mailTo
tag inside @ReportsCrashes
) the LogCat field isn't included to decrease the report size. To get around this you just need to use the customReportContent tag.
(Took a while of searching before I found this - it is written in the documentation, just not in the section mentioning LogCat)
@ReportsCrashes(formKey = "",
mailTo = "xxxx@yyyy.com",
customReportContent = {ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.STACK_TRACE, ReportField.LOGCAT },
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.crash_toast_text
)
Note: I excluded the USER_CONTENT and CUSTOM_DATA field
Note2: import org.acra.ReportField;
回答2:
I suppose it is because starting with JellyBean you cannot use READ_LOGS anymore. For further explanation read here:
http://commonsware.com/blog/2012/07/12/read-logs-regression.html
来源:https://stackoverflow.com/questions/14572385/logcat-empty-using-acra-on-device