Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Sep 1, 2015

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

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.