【问题标题】:An annotation argument must be a compile-time constant acra android注释参数必须是编译时常量 acra android
【发布时间】:2020-10-04 15:27:31
【问题描述】:

我正在尝试向我的应用添加 acra 支持,以便在应用崩溃时发送报告。我上课了:

@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)
    }
}

但我无法添加此行来定义我要发送的数据:

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

this example 这个字段是这样定义的:

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

但是这段代码不起作用:(我做错了什么以及如何将此信息添加到我的消息中?

【问题讨论】:

    标签: android kotlin


    【解决方案1】:

    我不知道你在 Array(5) 背后的意图,但这个可行,你应该能够从那里详细说明:

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

    【讨论】:

    • 但它没有向我发送任何我要发送的数据,例如 android 版本或类似的东西:(
    猜你喜欢
    • 2021-06-11
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多