¿Cómo puedo usar ACRA desde un Live Wallpaper?

I have a live wallpaper that crashes from time to time, and I would like to harvest the benefits of integrating ACRA (http://code.google.com/p/acra/) for generating and collecting crashreports in a google spreadsheet.

However I just couldn't integrate ACRA in my live wallpaper. Here is what I tried so far:

  1. Followed the basic setup guide (http://code.google.com/p/acra/wiki/BasicSetup)
  2. Initialized ACRA with ACRA.init(WallpaperService.getApplication()); in WallpaperService.onCreate()
  3. Annotated WallpaperService with @ReportsCrashes(formKey = "dFhXY3Y4N2NXXXXXXXXwM1g3Z1FZUVE6MQ", mode = ReportingInteractionMode.TOAST, forceCloseDialogAfterToast = false, resToastText = R.string.crash_text_toast)

When I build and deploy the app, it just crashes like before, and ACRA is not enabled.

It seems the problem stems from the fact that ACRA expects a subclass of Application to be annotated.

I am compiling my app for android 2.1-update and using latest version of ACRA (4.23 as of now), and running on a phone with android 2.3.4.

Any help is more than welcome!

preguntado el 08 de noviembre de 11 a las 15:11

I have a solution allready, but since I am new on stackoverflow I am not allowed to submit my solution in another 5 hours! :-/ Oh well. Here is a link to my minimal patch that makes it work: groups.google.com/group/acra-discuss/browse_thread/thread/… -

2 Respuestas

I missed the basic fact that Android Live Wallpapers can have an optional class extending android.app.Application referenced from its AndroidManifest.xml.

Using this class is the best way to include ACRA in your wallpaper because it allows ACRA to start at the earliest possible moment in the lifecycle of your wallpaper.

Simply create a class extending android.app.Application in your project and name it from the android:name attribute in the application element of your manifest. Example.

En tu manifiesto:

 android:name=".MyApplication" >

En MyApplication.java:

package com.mycompany.myapp;

import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;

@ReportsCrashes(resDialogIcon = R.drawable.icon, resToastText = R.string.crash_text_toast, formKey = "dFhXY3YXXXXXXXXXXXXXXZUVE6MQ", mode = ReportingInteractionMode.TOAST, forceCloseDialogAfterToast = false)
public class MyApplication extends android.app.Application {
    public void onCreate() {

respondido 17 nov., 11:21

I researched this further and found that ACRA per version 4.2.3 does not support Live Wallpapers. I decided to patch it to add this support. The patch can be found in este hilo.

Here is a small summary:

  1. Patch ACRA to support a second argument in the init() as per the thread in the link above.
  2. Annotate the WallpaperService class as you would annotate the Application class per the ACRA documentation.
  3. Initialize ACRA with the new init() en función de la onCreate() method of WallpaperService like this: ACRA.init(getApplication(),this);

I still haven't exhastively tested this, and there might be alot of bugs. But at least this is a start. I now get a toast and some data in a spreadsheet instead of the pesky force quit toast.

respondido 09 nov., 11:21

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.