Skip to content
yaming116 edited this page Feb 12, 2014 · 20 revisions

If you found a bug in ACRA, please file an issue in the Issues Tracker. You can also post your questions or suggestions to the Discussion Group.

ACRA allows your Android application to send Crash Reports to various destinations:

When a crash occurs, you can choose and configure 4 different ways of interacting with the user:

  • Silent (default): ACRA actions are not visible. The crash report is sent and then the default android crash system does its job (Force Close dialog)
  • Toast: When the crash occurs, ACRA displays a toast and simultaneously sends the report.
  • Notification: An optional toast is displayed on application crash, but the report is not sent immediately. A status bar notification is published warning the user that he should send a report. When selected, the notification displays a dialog asking for the authorization to send the report, with an optional user comment.
  • Dialog: since 4.3.0b1, experimental, allows to display a crash dialog without the need of a status bar notification.

This tutorial will guide you through installing ACRA in your application project.

If you have any question or comment regarding ACRA, post a message on the Discussion Group.

Setting-up your project

Step by step installation of the ACRA library in an existing application project, with the simplest settings:

  • Open your Eclipse project
  • Create a libs folder
  • Add the file acra-4.X.Y.jar in the libs folder
  • Right-click on the jar file / add to build path (should be done automatically if your Eclipse and ADT are up to date)
  • Create a new class in your package root If your app already contains an Application subclass, add ACRA to this class.
    • Give it a name like: MyApplication, make it extend android.app.Application
    • Above the declaration of the MyApplication class, add the @ReportsCrashes annotation with your backend formUri as a parameter
    import org.acra.*;
    import org.acra.annotation.*;

    @ReportsCrashes(
        formKey = "", // This is required for backward compatibility but not used
        formUri = "http://www.backendofyourchoice.com/reportpath"
    )
    public class MyApplication extends Application {
    }
  • Then override the onCreate() method to add the ACRA init statement. In our newly created class, it looks like:
    import org.acra.*;
    import org.acra.annotation.*;

    @ReportsCrashes(
        formKey = "", // This is required for backward compatibility but not used
        formUri = "http://www.backendofyourchoice.com/reportpath"
    )
    public class MyApplication extends Application {
        @Override
        public void onCreate() {
            super.onCreate();

            // The following line triggers the initialization of ACRA
            ACRA.init(this);
        }
    }

Please note that depending on the backend you selected, some additional parameters may be required. Please refer to the backend documentation.

  • Open the android manifest editor (AndroidManifest.xml)
    • In the Application tab, click on the Browse button next to the Name field
    • Select your newly created Application class (MyApplication). This adds an android:name attribute to your application element like this (put the full name with package if the application class package is not the same as manifest root element declared pakage):
<application android:icon="@drawable/icon" android:label="@string/app_name"
                android:name="MyApplication">
  • In the Permissions tab, add a Uses Permission object with value android.permission.INTERNET. This adds the following element as a child of the manifest element:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
  • THE END - next time your application crashes, it sends a report to your backend.

You can also browse the javadoc or get its archive here.

Is that all?

First of all, you should read Reports content for an explanation of the data collected by ACRA.

ACRA is designed to work with the simplest possible setup. But there are lots of configurable items, all described in the Advanced Usage Guide. Among them:

Clone this wiki locally