Custom ReportSender is not called
henrichg opened this issue · 8 comments
ACRA do not call my custom ReportSender.
Used example: https://github.com/ACRA/acra/tree/master/examples/acra-basic-java-example
My ACRA custom report sender:
Source: https://github.com/henrichg/PhoneProfilesPlus/blob/cd72b9b4c1f622177dc93d0f273473ddf4be91bd/phoneProfilesPlus/src/main/java/sk/henrichg/phoneprofilesplus/CustomACRAEmailSender.java
This working, method create() is called, several times:
@AutoService(ReportSenderFactory.class)
public static class CustomACRAEmailSenderFactory implements ReportSenderFactory {
@NotNull
@Override
public ReportSender create(@NotNull Context context, @NotNull CoreConfiguration coreConfiguration) {
Log.e("CustomACRAEmailSenderFactory.create", "#### ***** ####");
return new CustomACRAEmailSender(coreConfiguration);
}
}
But this not working, in logcat is not log called at start of method send():
@Override
public void send(@NotNull Context context, @NotNull CrashReportData errorContent)
throws ReportSenderException {
Log.e("CustomACRAEmailSender.send", "Report Sent!");
...
}
- Android: 13 (API level 33), but not working from Android 10. In Nexus 5x, Adroid 9, working, send() is called.
- ACRA: 5.9.7
- compileSDK: 33 (required for ACRA 5.9.7)
- targetSDK: 28
- language: Java
Report senders are called in a different process. make sure you're not filtering out the acra process logs.
Also in Andrid 9? Because in Nexus 5x is log in logcat, Android Studio displayed it.
Logs are not filtered by process: used is this filter, both for Nexus 5x and Galaxy S10:
package:sk.henrichg.phoneprofilesplus level:ERROR
In log, when I click OK button in ACRA notification, is also this:
12:45:38.739 PPApplication.attachBaseContext E ACRA.isACRASenderServiceProcess()
12:45:38.741 PPApplication.onCreate E onCreate() start
12:45:38.742 PPApplication.onCreate E ACRA.isACRASenderServiceProcess()
It is logged because of:
In PPApplication.attachBaseContext:
// This is required : https://www.acra.ch/docs/Troubleshooting-Guide#applicationoncreate
if (ACRA.isACRASenderServiceProcess()) {
Log.e("PPApplication.attachBaseContext", "ACRA.isACRASenderServiceProcess()");
return;
}
In PPApplication.onCreate:
// This is required : https://www.acra.ch/docs/Troubleshooting-Guide#applicationoncreate
if (ACRA.isACRASenderServiceProcess()) {
Log.e("PPApplication.onCreate", "ACRA.isACRASenderServiceProcess()");
return;
}
Result: In attachBaseContext is ACRA.init() called only once. Is this problem?
EDIT: logcat both from Nexus 5x (Android 9) and Galaxy S10 (Android 10)
In log for Nexus 5x is looged also call of send() = custom sender was called:
14:07:50.288 CustomACRAEmailSender.send E Report Sent!
14:07:50.288 CustomACRAEmailSender.send E plugins.size=2
14:07:50.288 CustomACRAEmailSender.send E MailSenderConfiguration
https://drive.google.com/file/d/1_7lk8VPP2GeQ-padZFQKlEsqONcPolJE/view?usp=drivesdk
You can try adding this to CustomACRAEmailSender:
@Override
public boolean requiresForeground() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
}
Hm thanks, working, but:
- Pixel 6, Android 13 QPR3, only GMail installed -> Gmail is called 2x. By me is called custom report sender and also internal report sender. In log is custom report sender only once.
- Galaxy S10, Android 10, GMail and Samsung Email installed -> GMail is called only once.
- Huawei P40 lite, EMUI 12, Android 10, only EMUI Email installed -> called 2x (one direct, one over Huawei Share). But in next few tests, only direct Email call. Hm, hm. maybe bug in Huawei EMUI 12. :-(
- Xiaomi Redmi Note 9 Pro, MIUI 13, Android 12, only GMail installed -> Gmail is called 2x. By me is called custom report sender and also internal report sender. In log is custom report sender only once.
- OnePlus 9, OxygenOS 13, Android 13, installed only GMail -> Gmail is called 2x. By me is called custom report sender and also internal report sender. In log is custom report sender only once.
- Pixel 3a, Android 12, only GMail istalled -> Gmail is called 2x. By me is called custom report sender and also internal report sender. In log is custom report sender only once.
- Galaxy S21, Android 13, only GMail installed -> GMail is called only once, because the internal report sender crashed.
In all tests crash_log.txt is attachet. This is good. :-)
Result: not good :-(
Is possible to disable internal report sender and using only custom?
All internal sender factories can be disabled using the respective configuration (enabled = false
). Just make sure your custom sender factory ignores that flag.
I think the reason for that you are reusing org.acra.config.MailSenderConfiguration
which is also used by the default MailSender. Since you don't use the config in your CustomACRAEmailSender
, simply remove withPluginConfigurations
call and the issue will probably be solved.
Thank you very much. It works. :-)
Added into custom ReportSender:
@Override
public boolean requiresForeground() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
}
And set enabled to false in configuration for MailSenderConfigurationBuilder():
.withEnabled(false) // must be false because of custom report sender