Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init ConfigurationBuilder using ReportsCrashes annotation #364

Closed
hexonxons opened this issue Feb 9, 2016 · 4 comments
Closed

Init ConfigurationBuilder using ReportsCrashes annotation #364

hexonxons opened this issue Feb 9, 2016 · 4 comments

Comments

@hexonxons
Copy link

Is there any way to init acra without using annotations on Application class but on my custom class?
For example

@ReportsCrashes(
        httpMethod = HttpSender.Method.PUT,
        reportType = HttpSender.Type.JSON,
        formUri = "http://example.com",
        formUriBasicAuthLogin = "reporter",
        formUriBasicAuthPassword = "reporter",
        mode = ReportingInteractionMode.TOAST,
        resToastText = R.string.crash_toast_text,
        customReportContent = {
                ReportField.REPORT_ID,
                ReportField.APP_VERSION_CODE,
                ReportField.APP_VERSION_NAME,
                ReportField.PACKAGE_NAME,
                ReportField.PHONE_MODEL,
                ReportField.ANDROID_VERSION,
                ReportField.BUILD,
                ReportField.BRAND,
                ReportField.PRODUCT,
                ReportField.TOTAL_MEM_SIZE,
                ReportField.AVAILABLE_MEM_SIZE,
                ReportField.CUSTOM_DATA,
                ReportField.STACK_TRACE,
                ReportField.CRASH_CONFIGURATION,
                ReportField.DISPLAY,
                ReportField.USER_APP_START_DATE,
                ReportField.USER_CRASH_DATE,
                ReportField.LOGCAT,
                ReportField.EVENTSLOG,
                ReportField.IS_SILENT,
                ReportField.DEVICE_ID,
                ReportField.INSTALLATION_ID,
                ReportField.DEVICE_FEATURES,
                ReportField.ENVIRONMENT,
                ReportField.THREAD_DETAILS
        },
        logcatArguments = {"-t", "500", "-v", "long", "*:D"}
)
public final class CrashReporters {
    ...
}

In acra 4.6.2 there was ACRAConfiguration(ReportsCrashes) constructor, but I found no way to do same thing in acra 4.8.1 and all other cases relies on application. Another way is to implement ConfigurationBuilder(Application app)'s logic, but it is quite strange.

@william-ferguson-au
Copy link
Member

The @ReportCrashes annotation must be on an Application class.

If you want to programmatically configure ACRA, it is quite simple. You just populate the ConfigurationBuilder with the values you want and then use it to create the ACRAConfiguration to use.

See https://github.com/ACRA/acra/wiki/BasicSetup#configuring-acra---programmatically

@hexonxons
Copy link
Author

@william-ferguson-au Well, ok, but there is no @ReportCrashes annotation on MyApplication class in that example. And .build(); method fails with

Caused by: java.lang.NullPointerException: Attempt to get length of null array
at org.acra.config.ACRAConfiguration.copyArray(ACRAConfiguration.java:1232)
at org.acra.config.ACRAConfiguration.<init>(ACRAConfiguration.java:113)
at org.acra.config.ConfigurationBuilder.build(ConfigurationBuilder.java:163)

cause annotationConfig.additionalDropBoxTags is null.

Is it wrong doc there?

@william-ferguson-au
Copy link
Member

Damn. That's an oversight.
I'll fix it tonight.

@william-ferguson-au
Copy link
Member

I have opened #365 to track the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants