2 android android-library acra
我正在尝试将我的应用程序项目转换为库,我收到的错误就像
resDialogTitle = R.string.crash_dialog_title,
The value for annotation attribute ReportsCrashes.resDialogTitle must be a constant expression
Run Code Online (Sandbox Code Playgroud)
它们用于ACRA标题
@ReportsCrashes(formKey = "--", mode = ReportingInteractionMode.DIALOG, mailTo = "--", customReportContent = {
ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME,
ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL,
ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT }
// resToastText = R.string.crash_toast_text, // optional, displayed as soon as
// the crash occurs, before collecting data which can take a few seconds
resDialogText = getString(R.string.crash_dialog_text),
resDialogIcon = android.R.drawable.ic_dialog_info, // optional.
// default
// is
// a
// warning
// sign
//resDialogTitle = R.string.crash_dialog_title, // optional. default is your
// application name
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt, // optional. when
// defined, adds
// a user text
// field input
// with this
// text resource
// as a label
resDialogOkToast = R.string.crash_dialog_ok_toast // optional. displays a Toast
// message when the user
// accepts to send a report.
)
public class MainAppClass extends Application {
private static MainAppClass singleton;
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
在ACRA中,自ADT 14以来,R字段在库项目中不是常量.2解决方案:
方法ACRA.getConfig()返回一个ACRAConfiguration对象,该对象为每个@ReportsCrashes配置项提供一个setter.
例如:
ACRA.getConfig().setResDialogText(R.string.crash_dialog_text);
Run Code Online (Sandbox Code Playgroud)
记得打电话给ACRA.init(这个); 在你的onCreate()方法中.
您可以通过这种方式设置所需的所有字段.请点击这里.
| 归档时间: |
|
| 查看次数: |
921 次 |
| 最近记录: |