首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android ACRA报告

Android ACRA报告
EN

Stack Overflow用户
提问于 2015-10-26 23:42:30
回答 1查看 2.1K关注 0票数 0

我正在尝试在我的测试应用程序(Lollipop)中使用Android中的ACRA来获得基本的报告。

到目前为止,我实施了以下措施:

  1. 增加等级中的依赖性 编译'ch.acra:acra:4.6.2‘
  2. 添加了扩展应用程序的MyApplication,并向其添加了ReportsCrashes注释: @ReportsCrashes( resNotifTickerText = R.string.crash_notification_ticker_text,resNotifTitle = R.string.crash_notification_title,resNotifText = R.string.crash_notification_text,resNotifIcon = R.mipmap.error );公共类MyApplication扩展应用程序{私有静态最终字符串标记= MyApplication.class.getSimpleName();@Override (){ super.onCreate();ACRA.init(this);}}

(顺便说一句,很抱歉上面的代码格式化,但是StackOverflow出于某种原因拒绝正确地格式化它)

这是基于github https://github.com/ACRA/acra/wiki/BasicSetup中提供的ACRA文档。

  1. 在AndroidManifest中添加应用程序名称和因特网权限
  2. 我的主要活动只有一个按钮,当点击它时,它将崩溃应用程序,当它试图做除法为零。 公共类MainActivity扩展了AppCompatActivity {公共最终静态字符串标记= MainActivity.class.getSimpleName();私有按钮btnError;@重载受保护的无效onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);btnError = ( Button ) findViewById(R.id.btnError);BtnError.setOnClickListener(新View.OnClickListener() {@覆盖公共无效onClick(View v) ){ Toast.makeText(getApplicationContext(),getString(R.string.toast_app_crash),Toast.LENGTH_SHORT).show();Runnable r=新Runnable() { @Override (){ //这将使应用程序崩溃,引发算术异常int号=7/ 0;};Handler h=新Handler();h.postDelayed(r,2000年);}};}

我希望看到某种通知和某种报告的生成,但我没有得到任何。我的应用程序只是在尝试零除法的地方崩溃。

我不知道我做错了什么。

谢谢,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-27 05:43:34

应选择的通知类型为

代码语言:javascript
复制
 mode = ReportingInteractionMode.TOAST,
   //Available : Dialog,Notification,Toast and Silent
    resToastText = R.string.crash_text_toast

下面是我在我的应用程序中使用的示例报表参数。

代码语言:javascript
复制
    @ReportsCrashes(
    formUri="",
formUriBasicAuthLogin = "CloundantAuthLogin",
formUriBasicAuthPassword = "CloundantAuthKeyPassword",
    reportType = org.acra.sender.HttpSender.Type.JSON,
    httpMethod = org.acra.sender.HttpSender.Method.PUT,
    customReportContent = { ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL,ReportField.DEVICE_FEATURES,
    ReportField.USER_APP_START_DATE,ReportField.USER_CRASH_DATE,ReportField.TOTAL_MEM_SIZE,ReportField.USER_COMMENT,
        ReportField.THREAD_DETAILS, ReportField.STACK_TRACE }, 
    mode = ReportingInteractionMode.DIALOG,
    includeDropBoxSystemTags  = true,
    resToastText = R.string.crash_toast_text, // optional, displayed as soon as the crash occurs, before collecting data which can take a few seconds
    resDialogText = 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.
    )

使用的图书馆: acra-4.6.2

这里提供的最好的教程是:http://www.toptal.com/android/automated-android-crash-reports-with-acra-and-cloudant

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33357506

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档