2021年5月4日星期二

ACRA toast appearing, but cannot explain why

I have a complex Android app that uses ACRA for error reporting, which generally works fine.

Except, on one test device, I now see the ACRA toast appearing, during app startup, and then disappearing. But the app keeps running, and I get no report. It's as if an error happened, but nothing but a toast appeared. I find no clues in logcat.

But if I force a report by throwing an exception, I get the same toast, and I get the report posted to my server, and the app quits, all of which is desired behavior.

I've tried to track this down by adding a custom ReportingAdministrator just for the purpose of getting a stack trace. This works for my forced exception, but does get called for the mystery toast - the toast is displayed, but my administrator class method does not get called.

Any suggestions on how to find the cause of this errant toast event?

Note: ACRA is normally called by MyExceptionInterceptor. On an uncaught exception, it grabs some text and puts it uses the ACRA error report to add it to the report. It then calls ACRA.getErrorReporter().handleException(t, true);

Whatever is causing the ACRA toast to appear is not going through this path. I have not been able to find anywhere to set a breakpoint to catch it.

Setup code:

           int acraLimitPerTime = VersionHelper.isDevelVersion() ? 1000 : 2;              CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)                      .setBuildConfigClass(BuildConfig.class)                      .setReportFormat(StringFormat.KEY_VALUE_LIST)                      .setStopServicesOnCrash(true)                      .setReportSendFailureToast("Error report could not be sent")                      .setReportSendSuccessToast("Error report was sent")                      .setEnabled(true)                      .setExcludeMatchingSharedPreferencesKeys("^lat$", "^lng$");              builder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder.class)                      .setUri(ISOL.URL_ACRA_REPORT)                      .setHttpMethod(HttpSender.Method.POST)                      .setBasicAuthLogin("*****")                      .setBasicAuthPassword("*****")                      .setEnabled(true);              builder.getPluginConfigurationBuilder(ToastConfigurationBuilder.class)                      .setLength(Toast.LENGTH_LONG) //===jrm                      .setText("An error has occurred and a report is being sent to the developer.")                      .setEnabled(true);              builder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class)                      .setPeriodUnit(TimeUnit.HOURS)                      .setPeriod(1)                      .setOverallLimit(acraLimitPerTime)                      .setEnabled(true);                  // The following line triggers the initialization of ACRA              ACRA.init(this, builder);              ACRA.getErrorReporter().putCustomData("BUILDDTG", MyBuildConstants.buildDTG);              new MyExceptionInterceptor().setUpFatalExceptionHandling();  
https://stackoverflow.com/questions/67393945/acra-toast-appearing-but-cannot-explain-why May 05, 2021 at 09:04AM

没有评论:

发表评论