Andrew
Andrew

Reputation: 2157

An annotation argument must be a compile-time constant acra android

I'm trying to add acra support to my app for sending reports when app crashes. I did class:

@ReportsCrashes(formUri = "",
        mailTo = "****@gmail.com",
        mode = ReportingInteractionMode.TOAST,
        customReportContent = Array<ReportField>(5) { i: Int -> ReportField.ANDROID_VERSION },
        resToastText = R.string.crash_toast_text)

class AcraReports : Application() {
    override fun onCreate() {
        super.onCreate()
        ACRA.init(this)
    }
}

but I can't add this line for defining data which I would like to send:

customReportContent = Array<ReportField>(5) { i: Int -> ReportField.ANDROID_VERSION },

At this example this field is defined in such way:

customReportContent = { /* */ReportField.APP_VERSION_NAME, ReportField.PACKAGE_NAME,ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL,ReportField.LOGCAT },

but this code doesn't work :( What I did wrong and how to add this info to my message?

Upvotes: 0

Views: 1076

Answers (1)

ror
ror

Reputation: 3500

I don't know your intention behind Array(5) but this one works and you should be able to elaborate from there:

@ReportsCrashes(
    formUri = "",
    formKey = "the key",
    mailTo = "****@gmail.com",
    mode = ReportingInteractionMode.TOAST,
    customReportContent = [ReportField.ANDROID_VERSION],
    resToastText = R.string.crash_toast_text
)

Upvotes: 1

Related Questions