简体   繁体   English

如何向开发人员发送崩溃报告?

[英]How to send crash reports to developer?

I develop android app but in some cases my app force close 我开发Android应用程序但在某些情况下我的应用程序force close

How can I send email to developer contains details if force close happen in any time ? 如果在任何时候发生force close我如何向开发者发送电子邮件包含详细信息?

The ACRA library will fulfill your requirement. ACRA图书馆将满足您的要求。 You just need to setup the email. 您只需要设置电子邮件。 The tutorial and setup is defined here. 本教程和设置在此处定义

Download the library with .jar in lib 在lib中使用.jar下载库

You just need to define the Application class and write the following code just above application class and override onCreate() method like this 您只需要定义Application类并在应用程序类之上编写以下代码并覆盖onCreate()方法,就像这样

     @ReportsCrashes(formKey = "", // will not be used
                    mailTo = "reports@yourdomain.com",
                    mode = ReportingInteractionMode.TOAST,
                    resToastText = R.string.crash_toast_text)
    public class MyApplication extends Application {

 @Override
    public void onCreate() {
        ACRA.init(this);
        super.onCreate();
    }

}

Thats it. 而已。 The email action will get opened whose body contains crash report. 电子邮件操作将打开,其正文包含崩溃报告。

You can Use ready APi Such as BugSence and crittercism 您可以使用准备好的APi ,例如BugSencecrittercism

After implementation SDK you will recive crush report with crush logs to your email if you whant 在实施SDK之后,如果您愿意,可以将粉碎日志记录到您的电子邮件中

For BugSance Download SDK 对于BugSance下载SDK

import com.bugsense.trace.BugSenseHandler;

Make sure you also add the line 确保您还添加了该行

 <uses-permission android:name="android.permission.INTERNET" />

to your app's AndroidManifest.xml file. 到你的应用程序的AndroidManifest.xml文件。 BugSense uses this permission to send the crash reports and performance metrics. BugSense使用此权限发送崩溃报告和性能指标。

add the BugSenseHandler in your activity before setContentView. 在setContentView之前在您的活动中添加BugSenseHandler。 Then you are ready to go! 然后你准备好了!

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BugSenseHandler.initAndStartSession(Context, APIKEY);
    setContentView(R.layout.main);
    //rest of your code here
  }

The InitAndStartSession method installs the BugSense exception handler and the performance monitor. InitAndStartSession方法安装BugSense异常处理程序和性能监视器。 It then sends all the previously saved crash reports and performance metrics. 然后,它会发送所有以前保存的崩溃报告和性能指标。 At the same time, it starts a new session for your activity. 同时,它会为您的活动启动一个新会话。

Here's an example on how to use the InitAndStartSession: 以下是如何使用InitAndStartSession的示例:

BugSenseHandler.initAndStartSession(MyActivity.this, "YOURAPIKEY");

Whenever you want to explicitly start the session, you can use the startSession method at the onStart method of your activity, as follows: 无论何时想要显式启动会话,都可以在活动的onStart方法中使用startSession方法,如下所示:

BugSenseHandler.startSession(MyActivity.this);

Whenever you want to close the session, you can use the closeSession method as follows: 每当要关闭会话时,可以使用closeSession方法,如下所示:

BugSenseHandler.closeSession(MyActivity.this);

Close session will close the current session, offering better tracking of the sessions for your users. 关闭会话将关闭当前会话,为您的用户提供更好的会话跟踪。

If you want to manually flush all the saved data, use the BugSenseHandler.flush(Context) method: 如果要手动刷新所有已保存的数据,请使用BugSenseHandler.flush(Context)方法:

BugSenseHandler.flush(MyActivity.this);

More Documentation Android BugSence Doc 更多文档Android BugSence Doc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM