Thursday , August 16 2018
Home / Android / Email crash report using ACRA

Email crash report using ACRA

It would be great to get a detailed report every time your app crashes.
And that’s exactly what we’re gonna do in this post.

I’l be using ACRA, a wonderfully simple crash reporting library.Its also well documented.




A brief intro into ACRA :
1. It is capable of creating detailed reports on every app crash.
2. To obtain the report, ACRA can be configured in the following ways:

  • Send it to various supported backends.
  • Send it to your custom backend.
  • Send it via email.
  • Implement your own report handler.

Well, it already has an option to email the report !! Then why this post ?
Because for emailing, ACRA prompts the user to manually choose the emailing app (The intent chooser basically). This is simply an overhead.

So here’s what we’re gonna do.
We implement our own custom report handler.
This handler will capture the report and email it silently without the user knowing about it.
This method must be employed only during the testing phase of the app. Emailing silently from a production app will attract a lot of angry users, plus legal issues.

Let’s do some code :).

A brief overview of the classes used:
1. ACRAReportSender – Our custom report handler.
2. MyApplication – Our application class (to initialize ACRA).
3. MainActivity – Our launcher activity (to test the report sender).
4. GMailSender , JSSEProvider – Helper classes for ACRAReportSender.

You’ll need the following jars :



Here are the classes :
The application class – To configure ACRA.

Our custom report handler.

I’ve extracted only the basic data required. For a complete list of available data, refer this.

Helper for class for sending the email.

Another helper class
Finally , The launcher activity to test this out.

And yes, the AndroidManifest.xml

Important :

  •  <uses-permission android:name=”android.permission.INTERNET”/>MUST BE DECLARED in the manifest. This required by ACRA to send the email.
  •  android:name=”MyApplication” MUST BE DECLARED in the application tag. Otherwise ACRA will not work.

A Few Notes :

  • In this line :                                                                                                                                                              ACRAReportSender reportSender = new ACRAReportSender(“yourEmail@gmail.com”, “yourPassword”);
  • Your are exposing your email’s username and password. This is a security threat and hence must be used only when the app is in the testing phase,

  • I’m afraid the class GMailSender has been configured for gmail only. You may have to change it to suit your email provider.
  • If you have any kind of trouble setting up ACRA, refer ACRA Setup. Its super simple.




About admin

Check Also

Android Activity Launch Modes

Launch mode is an instruction for Android OS which specifies how the activity should be ...

Leave a Reply