Отправка отчетов по электронной почте с помощью ACRA (версия 5.7.0) на Android не работает

Я пытаюсь захватить журналы сбоев и отправить их по почте с помощью ACRA. Но почта не получена.

Я сделал следующее:

<сильный>1. Инициализирован ACRA внутри метода oncreate основного действия

ACRA.init(getApplication()); 

<сильный>2. Указано содержание отчета

@AcraCore(reportContent = {
        ReportField.REPORT_ID,
        ReportField.USER_APP_START_DATE,
        ReportField.USER_CRASH_DATE,
        ReportField.APP_VERSION_CODE,
        ReportField.APP_VERSION_NAME,
        ReportField.ANDROID_VERSION,
        ReportField.DEVICE_ID,
        ReportField.BRAND,
        ReportField.BUILD,
        ReportField.DEVICE_FEATURES,
        ReportField.PACKAGE_NAME,
        ReportField.REPORT_ID,
        ReportField.STACK_TRACE,
        ReportField.APPLICATION_LOG,
        ReportField.LOGCAT,
        ReportField.USER_EMAIL
},
        reportFormat = JSON,
        reportSenderFactoryClasses = {MainActivity.ACRASenderFactory.class}

)

<сильный>3. Класс Acrareportsender ниже

public class ACRAReportSender implements ReportSender {
    public ACRAReportSender(){
        Log.e("ACRA", "Report Sender created");
    }
    @Override

    public void send(Context context, CrashReportData crashReportData) throws ReportSenderException {
        Log.e("ACRA", "Before sending crash report");
        String reportBody = createCrashReport(crashReportData);
        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.setType("vnd.android.cursor.dir/email");
        String mail[] = {"[email protected]"};
        emailIntent.putExtra(Intent.EXTRA_EMAIL, mail);
        emailIntent.putExtra(Intent.EXTRA_TEXT, reportBody);
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "ACRA Crash Report");
        context.startActivity(Intent.createChooser(emailIntent, "Send crash to developers by email ..."));
    }
    public String createCrashReport(CrashReportData crashReportData){
        StringBuilder body = new StringBuilder();
        body.append("Device : " + crashReportData.getString(ReportField.BRAND) + " - " + crashReportData.getString(ReportField.PHONE_MODEL))
                .append("\n")
                .append("Android Version : " + crashReportData.getString(ReportField.ANDROID_VERSION))
                .append("\n")
                .append("App Version : " + crashReportData.getString(ReportField.APP_VERSION_CODE))
                .append("\n")
                .append("STACK TRACE : \n" + crashReportData.getString(ReportField.STACK_TRACE));
        return body.toString();

    }
}

<сильный>4. Класс AcraSenderFactory

public class ACRASenderFactory implements ReportSenderFactory {
    public ACRASenderFactory(){
        Log.e("ACRA", "Creating Sender Factory");
    }

    @NonNull
    public ReportSender create(Context context, CoreConfiguration acraConfiguration) {
        Log.e("ACRA", "Returning Report Sender");
        return new ACRAReportSender();
    }
}

Вывод, проверенный с помощью logcat (приведен ниже)

1. 09-01 20:36:06.063  3938  3938 I ACRA    : ACRA is enabled for com.example.myapplication, initializing..    

2. ACRA    : ACRA caught a RuntimeException for com.example.myapplication     

3. 09-01 20:36:06.529  3938  3938 D ACRA    : Building report
09-01 20:36:06.535  3938  4022 D ACRA    : Calling collector org.acra.collector.LogCatCollector
09-01 20:36:06.536  3938  4020 D ACRA    : Calling collector org.acra.collector.DropBoxCollector
09-01 20:36:06.536  3938  4020 D ACRA    : Collector org.acra.collector.DropBoxCollector completed
09-01 20:36:06.536  3938  4020 D ACRA    : Calling collector org.acra.collector.ReflectionCollecto..................
.......................

....................
ACRA    : ServicePluginLoader loading services from ServiceLoader : java.util.ServiceLoader[org.acra.sender.ReportSenderFactory].......
...........................................
...........................................
09-01 20:36:06.586  3938  4010 D ACRA    : Ignoring disabled ReportSenderFactory of type EmailIntentSenderFactory
09-01 20:36:06.586  3938  4010 D ACRA    : reportSenderFactories : []

............................................................................ ............................................................................

09-01 20:36:06.590  3938  4010 D ACRA    : Checking plugin Configuration : org.acra.config.SchedulerConfiguration@1d3f9ef against plugin class : class org.acra.config.HttpSenderConfiguration
09-01 20:36:06.590  3938  4010 D ACRA    : Checking plugin Configuration : org.acra.config.HttpSenderConfiguration@b426cfc against plugin class : class org.acra.config.HttpSenderConfiguration
**09-01 20:36:06.591  3938  4010 D ACRA    : Ignoring disabled ReportSenderFactory of type HttpSenderFactory**

..............................................................
.............................................................
.............................................................
09-01 20:36:06.616  3938  3938 D ACRA    : Ignoring disabled ReportInteraction of type NotificationInteraction
09-01 20:36:06.616  3938  3938 D ACRA    : Mark 2020-09-01T20:36:06.565+05:30.stacktrace as approved.
09-01 20:36:06.617  3938  3938 D ACRA    : Schedule report sending
09-01 20:36:06.626  3938  3938 D ACRA    : config#reportSenderFactoryClasses : ImmutableList{[]}
09-01 20:36:06.626  3938  3938 D ACRA    : Using PluginLoader to find ReportSender factories

В приведенных выше журналах говорится

a. Acra is getting initialized
b. acra is catching crash
c. report is approved

Запрос:

  **1. Where am i going wrong. why is it not sending mail**
  2. Is this, **"Ignoring disabled ReportSenderFactory of type HttpSenderFactory"**, as seen from the logs, the reason for not receiving reports via mail? If yes, how this can be rectified ?

Примечание: в файле манифеста предоставляется доступ в Интернет


person BrajeshNP    schedule 01.09.2020    source источник


Ответы (1)


Ваш ReportSenderFactory не может быть внутренним классом. Либо сделайте его классом верхнего уровня, либо объявите его статическим. Он также не должен быть абстрактным.

person F43nd1r    schedule 02.09.2020
comment
Я переместил ReportsenderFactory в класс верхнего уровня и удалил static. До сих пор отчеты не приходят мне на почту. Я инициализирую ACRA ( ACRA.init ) в основном классе активности, имею класс reportender и senderfactory в двух разных файлах. Мой вопрос: когда я инициализирую ACRA, запускается ли он отдельно в потоке, отличном от основного потока приложения, и отслеживает поток приложения на предмет любых исключений и перехватывает их всякий раз, когда это происходит, и отправляет отчет? или его нужно специально вызывать внутри основного класса активности - person BrajeshNP; 03.09.2020
comment
Вы читали github.com/ACRA/acra/wiki/BasicSetup? - person F43nd1r; 04.09.2020
comment
Спасибо... Это сработало... мне не хватило некоторых основных пунктов настройки - person BrajeshNP; 04.09.2020