2

The ACRA documentation to integrate crash reporting consists of 3 simple steps:

1 - Install the ACRA library

2 - Add the following to the AndroidManifest.xml

<!-- in the manifest, not the application tag -->
<uses-permission android:name="android.permission.INTERNET" />

and

<application ... android:name=".MyApplication">
    ...
</application>

3 - Create a new java class with the same name as above 'MyApplication':

import org.acra.*;
import org.acra.annotation.*;

@ReportsCrashes(formUri = "http://www.yourselectedbackend.com/reportpath")
public class MyApplication extends Application {
  @Override
  public void onCreate() {
    // The following line triggers the initialization of ACRA
    super.onCreate();
    ACRA.init(this);
  }
}

That's supposed to be it. I think the instructions are a bit out of date and that the AndroidManifest.xml has evolved since then.

I also needed to add the following inside my <application> ... </application> for it to function:

<service android:name="org.acra.sender.SenderService" />

Question: Am I doing something wrong or have Android requirements evolved and I'm doing it correctly?

Either way I also want to share/document my steps in case others have the same problems.

Community
  • 1
  • 1
Cyrille
  • 3,427
  • 1
  • 30
  • 32
  • 1
    "That's supposed to be it" -- that pretty much is it, at least if you are using Android Studio. "I think the instructions are a bit out of date" -- not that I am aware of, but they are definitely optimized for Android Studio. "the AndroidManifest.xml has evolved since then" -- not really. There are things that you might also put in the manifest related to ACRA (e.g., `org.acra.CrashReportDialog` `` element), but those are pretty much opt-in. – CommonsWare Mar 15 '16 at 14:58
  • 2
    Also, FWIW, I released [my book chapter on ACRA](https://commonsware.com/blog/2015/12/17/book-excerpt-crash-reporting-acra.html) late last year for free, which walks through setting up ACRA in an Android Studio project. – CommonsWare Mar 15 '16 at 15:00

1 Answers1

7

A more up-to-date basic setup instructions can be found on ACRA's GitHub Wiki: https://github.com/ACRA/acra/wiki/BasicSetup

Declaring the SenderService

ACRA (4.8+) uses the SenderService to send reports so it needs to be configured in your AndroidManifest.

If you are using manifest merging then the SenderService will be automatically included for you. Otherwise you will also need to configure a service that will send the reports. It should look like:

    <service
        android:name="org.acra.sender.SenderService"
        android:exported="false"
        android:process=":acra" />

NB the android:process ensures that the service runs in the :acra process. The intent is that that process is different from the default process for your application to ensure that the reports can be sent even though your app will be in shutdown mode if it has crashed.

It is likely that the documentation site has not been updated yet with the recent updates on the GitHub site.

Joe
  • 14,039
  • 2
  • 39
  • 49
  • That `` element will be added automatically if you are using Android Studio and using the ACRA artifact (that's the "If you are using manifest merging..." part). You might still need to manually add it if you are using Eclipse or otherwise are either not using Gradle or not using the ACRA AAR. – CommonsWare Mar 15 '16 at 14:55
  • Great! The newer instructions do have a few important differences that are helpful for me. Thanks! – Cyrille Mar 16 '16 at 13:08