-
Notifications
You must be signed in to change notification settings - Fork 2
BasicSetup
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:
- Deprecated - a Google Docs spreadsheet (default and original behavior) - please read this notice beforehand
- your own server-side HTTP POST script
- various existing backends
- any other possible destination by implementing your own report sender
- an email
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.
Step by step installation of the ACRA library in an existing application project, with the simplest settings:
- Open your Eclipse project
- Create a
libsfolder - Add the file
acra-4.X.Y.jarin thelibsfolder - 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 extendandroid.app.Application - Above the declaration of the
MyApplicationclass, add the@ReportsCrashesannotation with your backendformUrias a parameter
- Give it a name 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 {
}- 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 anandroid:nameattribute to yourapplicationelement 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 themanifestelement:
<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.
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:
-
- SILENT (default): with the basic setup, ACRA sends reports silently, without warning your users, and lets the system display the native Force Close dialog (which may include Android Market Send Report button on android 2.1+ devices... if your app has been downloaded from the market).
- TOAST: displays a Toast with the text of your choice when the app crashes but doesn't allow your user to prevent reports from being sent (but you can setup a SharedPreference item).
- NOTIFICATION: displays a Toast when the app crashes, then a notification in the status bar asking your user to send a report. When the notification is selected, a Dialog asks for authorization + optional user comment.
- DIALOG: displays a Toast when the app crashes, then displays a Dialog on application restart asking for authorization + optional user comment.
-
- GoogleDocs Form (default): the most used (and default) destination for crash reports with ACRA is a GoogleDocs Form. The data is stored in a GoogleDocs spreadsheet. This allows you to setup crash reporting without having to care about implementing a server-side script and find good quality (cheap) hosting. You use Google's infrastructure, for free.
- Custom server script: if you want to have better control over the reports, you can implement your own server-side script to handle reports and host it somewhere else. Then you can configure ACRA to send reports to this script.
- E-mail: if your application does not require internet permission and you don't want to add it only for crash reporting, you can configure ACRA to send reports by e-mail. This means that when a crash occurs, the user has to choose the e-mail app he prefers before reviewing the crash report and sending it.
- Any destination you can imagine: there is a simple Interface you can implement to provide your own report sender to ACRA. ACRA gives your class the report data, you do whatever you want with it.
-
Reports content: ACRA provides extensive device information and state data in default reports. In addition, you can:
-
User preferences: you can add to your app preferences screen some items to let users control ACRA's behavior and reports content: