Skip to content

Instantly share code, notes, and snippets.

@ashtom
Created March 1, 2012 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashtom/1948535 to your computer and use it in GitHub Desktop.
Save ashtom/1948535 to your computer and use it in GitHub Desktop.
Example Application class for HockeyApp and ACRA
package net.hockeyapp.android.demo;
import org.acra.ACRA;
import org.acra.annotation.ReportsCrashes;
import android.app.Application;
// Replace APP_ID with your App ID on HockeyApp
@ReportsCrashes(formKey="APP_ID")
public class MyApplication extends Application {
@Override
public void onCreate() {
ACRA.init(this);
ACRA.getErrorReporter().setReportSender(new HockeySender());
super.onCreate();
}
}
@Frank1234
Copy link

formKey is deprecated from Acra 4.5+. Use:

    @ReportsCrashes(buildConfigClass = MyApplication.class)
    public class MyApplication extends Application {
        ...

and in your HockeySender, if you use it:

    @Override
    public void send(Context context, CrashReportData errorContent) throws ReportSenderException {

        String formKey = context.getString(R.string.acra_form_key);
        String url = BASE_URL + formKey + CRASHES_PATH;
        ...

@v-JohnZhang
Copy link

v-JohnZhang commented May 6, 2016

@ReportsCrashes(buildConfigClass = MyApplication.class) has been edited from 4.8.0+ , use

@ReportsCrashes(reportSenderFactoryClasses ={HockeySenderFactory.class})
public class MyApplication extends Application

ACRA.getErrorReporter().setReportSender(new HockeySender()); has been removed also, so we don't use this method again. We should create a class HockeySenderFactory implements ReportSenderFactory, like the code bellow:

public class HockeySenderFactory implements ReportSenderFactory {
    @NonNull
    @Override
    public ReportSender create(Context context, ACRAConfiguration config) {
        return new HockeySender();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment