0

Im trying to capture the crash logs and send it via mail using ACRA. But the mail is not received.

I have done the following :

1. Initialized ACRA inside the oncreate method of the main activity

ACRA.init(getApplication()); 

2. Specified the Report content

@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 class below

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[] = {"brajesh.poovakkad@gmail.com"};
        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 Class

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();
    }
}

Output as verified from logcat ( provided below)

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

The above logs says

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

Query:

  **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 ?

Note: in manifest file, Internet permission is provided

1 Answer 1

1

Your ReportSenderFactory cannot be an inner class. Either make it a toplevel class or declare it static. It also must not be abstract.

3
  • i have moved the ReportsenderFactory to top level class and removed static. Still the reports are not coming to my mail. I'm initializing ACRA ( ACRA.init ) in the main activity class, have reportsender and senderfactory class in two different files. My question is , when i initialize ACRA, does it run seperately in a different thread than the app's main thread and monitor the app thread for any exceptions and catch them whenever it happens and send the report ? or does it need to be specifically invoked inside the main activity class
    – BrajeshNP
    Sep 3, 2020 at 17:10
  • 1
    Did you read github.com/ACRA/acra/wiki/BasicSetup?
    – F43nd1r
    Sep 4, 2020 at 1:59
  • Thanks... It worked...i was missing some of the basic setup points
    – BrajeshNP
    Sep 4, 2020 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.