Application Crash Reporting for Android
ACRA is a Google library that allows your Android applications to automatically log unhandled exceptions or application crashes to a Google document and/or display Toast notifications.
To use it, you’ll need to create an Application class at the root of your Android application. This class will be used to log any uncaught or unhandled Exceptions, and will contain ACRA’s configuration.
Here’s a sample Application class:
package com.justinschultz.android; import java.lang.Thread.UncaughtExceptionHandler; import org.acra.ACRA; import org.acra.annotation.ReportsCrashes; import android.app.Application; import android.util.Log; @ReportsCrashes(formKey = "YOURFORMKEY") public class MyApplication extends Application implements UncaughtExceptionHandler { private static MyApplication instance; public MyApplication() { instance = this; Thread.setDefaultUncaughtExceptionHandler(this); } @Override public void onCreate() { ACRA.init(this); super.onCreate(); } public static MyApplication getInstance() { return instance; } @Override public void uncaughtException(Thread thread, Throwable ex) { Log.i("Error: ", (ex == null || ex.getMessage() == null) ? "Unknown" : ex.getMessage()); } }
Here’s how to generate a form key and complete the configuration.
About this entry
You’re currently reading “ Application Crash Reporting for Android ,” an entry on Public Static Droid Main
- Published:
- 1.6.12 / 9pm
- Category:
- Uncategorized
No comments
Jump to comment form | comments rss [?] | trackback uri [?]