简体   繁体   English

如何从我的 Android 应用程序获取崩溃数据?

[英]How do I obtain crash-data from my Android application?

How can I get crash data (stack traces at least) from my Android application?如何从我的 Android 应用程序获取崩溃数据(至少是堆栈跟踪)? At least when working on my own device being retrieved by cable, but ideally from any instance of my application running on the wild so that I can improve it and make it more solid.至少在我自己的设备上工作时通过电缆检索,但理想情况下是从我的应用程序的任何实例中运行,以便我可以改进它并使其更可靠。

You might try the ACRA (Application Crash Report for Android) library:您可以尝试ACRA(Android 应用程序崩溃报告)库:

ACRA is a library enabling Android Application to automatically post their crash reports to a GoogleDoc form. ACRA 是一个库,使 Android 应用程序能够自动将其崩溃报告发布到 GoogleDoc 表单。 It is targetted to android applications developers to help them get data from their applications when they crash or behave erroneously.它面向 android 应用程序开发人员,帮助他们在应用程序崩溃或出现错误时从他们的应用程序中获取数据。

It's easy to install in your app, highly configurable and don't require you to host a server script anywhere... reports are sent to a Google Doc spreadsheet !它很容易安装在您的应用程序中,高度可配置,并且不需要您在任何地方托管服务器脚本......报告被发送到 Google Doc 电子表格!

For sample applications and debugging purposes, I use a simple solution that allows me to write the stacktrace to the sd card of the device and/or upload it to a server.对于示例应用程序和调试目的,我使用了一个简单的解决方案,该解决方案允许我将堆栈跟踪写入设备的 SD 卡和/或将其上传到服务器。 This solution has been inspired by Project android-remote-stacktrace (specifically, the save-to-device and upload-to-server parts) and I think it solves the problem mentioned by Soonil.这个解决方案的灵感来自 Project android-remote-stacktrace (特别是保存到设备和上传到服务器部分),我认为它解决了 Soonil 提到的问题。 It's not optimal, but it works and you can improve it if you want to use it in a production application.它不是最佳的,但它有效,如果你想在生产应用程序中使用它,你可以改进它。 If you decide to upload the stacktraces to the server, you can use a php script ( index.php ) to view them.如果您决定将堆栈跟踪上传到服务器,您可以使用 php 脚本 ( index.php ) 来查看它们。 If you're interested, you can find all the sources below - one java class for your application and two optional php scrips for the server hosting the uploaded stacktraces.如果您有兴趣,您可以在下面找到所有来源 - 一个用于您的应用程序的 java 类和两个用于托管上传的堆栈跟踪的服务器的可选 php 脚本。

In a Context (eg the main Activity), call在上下文(例如主活动)中,调用

if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
    Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(
            "/sdcard/<desired_local_path>", "http://<desired_url>/upload.php"));
}

CustomExceptionHandler

public class CustomExceptionHandler implements UncaughtExceptionHandler {

    private UncaughtExceptionHandler defaultUEH;

    private String localPath;

    private String url;

    /* 
     * if any of the parameters is null, the respective functionality 
     * will not be used 
     */
    public CustomExceptionHandler(String localPath, String url) {
        this.localPath = localPath;
        this.url = url;
        this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
    }

    public void uncaughtException(Thread t, Throwable e) {
        String timestamp = TimestampFormatter.getInstance().getTimestamp();
        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);
        e.printStackTrace(printWriter);
        String stacktrace = result.toString();
        printWriter.close();
        String filename = timestamp + ".stacktrace";

        if (localPath != null) {
            writeToFile(stacktrace, filename);
        }
        if (url != null) {
            sendToServer(stacktrace, filename);
        }

        defaultUEH.uncaughtException(t, e);
    }

    private void writeToFile(String stacktrace, String filename) {
        try {
            BufferedWriter bos = new BufferedWriter(new FileWriter(
                    localPath + "/" + filename));
            bos.write(stacktrace);
            bos.flush();
            bos.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void sendToServer(String stacktrace, String filename) {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("filename", filename));
        nvps.add(new BasicNameValuePair("stacktrace", stacktrace));
        try {
            httpPost.setEntity(
                    new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
            httpClient.execute(httpPost);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

upload.php

<?php
    $filename = isset($_POST['filename']) ? $_POST['filename'] : "";
    $message = isset($_POST['stacktrace']) ? $_POST['stacktrace'] : "";
    if (!ereg('^[-a-zA-Z0-9_. ]+$', $filename) || $message == ""){
        die("This script is used to log debug data. Please send the "
                . "logging message and a filename as POST variables.");
    }
    file_put_contents($filename, $message . "\n", FILE_APPEND);
?>

index.php

<?php
    $myDirectory = opendir(".");
    while($entryName = readdir($myDirectory)) {
        $dirArray[] = $entryName;
    }
    closedir($myDirectory);
    $indexCount = count($dirArray);
    sort($dirArray);
    print("<TABLE border=1 cellpadding=5 cellspacing=0 \n");
    print("<TR><TH>Filename</TH><TH>Filetype</th><th>Filesize</TH></TR>\n");
    for($index=0; $index < $indexCount; $index++) {
        if ((substr("$dirArray[$index]", 0, 1) != ".") 
                && (strrpos("$dirArray[$index]", ".stacktrace") != false)){ 
            print("<TR><TD>");
            print("<a href=\"$dirArray[$index]\">$dirArray[$index]</a>");
            print("</TD><TD>");
            print(filetype($dirArray[$index]));
            print("</TD><TD>");
            print(filesize($dirArray[$index]));
            print("</TD></TR>\n");
        }
    }
    print("</TABLE>\n");
?>

You can also try [BugSense] Reason: Spam Redirect to another url .您也可以尝试 [BugSense] Reason: Spam Redirect to another url BugSense collects and analyzed all crash reports and gives you meaningful and visual reports. BugSense 收集和分析所有崩溃报告,并为您提供有意义和直观的报告。 It's free and it's only 1 line of code in order to integrate.它是免费的,只需 1 行代码即可集成。

Disclaimer: I am a co-founder免责声明:我是联合创始人

In Android 2.2 it's now possible to automatically get Crash Reports from Android Market Applications:在 Android 2.2 中,现在可以从 Android Market 应用程序自动获取崩溃报告:

New bug reporting feature for Android Market apps enables developers to receive crash and freeze reports from their users. Android Market 应用程序的新错误报告功能使开发人员能够从用户那里接收崩溃和冻结报告。 The reports will be available when they log into their publisher account.当他们登录到他们的发布者帐户时,这些报告将可用。

http://developer.android.com/sdk/android-2.2-highlights.htmlhttp://developer.android.com/sdk/android-2.2-highlights.html

It is possible to handle these exceptions with Thread.setDefaultUncaughtExceptionHandler() , however this appears to mess with Android's method of handling exceptions.可以使用Thread.setDefaultUncaughtExceptionHandler()处理这些异常,但这似乎与 Android 处理异常的方法相混淆。 I attempted to use a handler of this nature:我试图使用这种性质的处理程序:

private class ExceptionHandler implements Thread.UncaughtExceptionHandler {
    @Override
    public void uncaughtException(Thread thread, Throwable ex){
        Log.e(Constants.TAG, "uncaught_exception_handler: uncaught exception in thread " + thread.getName(), ex);

        //hack to rethrow unchecked exceptions
        if(ex instanceof RuntimeException)
            throw (RuntimeException)ex;
        if(ex instanceof Error)
            throw (Error)ex;

        //this should really never happen
        Log.e(Constants.TAG, "uncaught_exception handler: unable to rethrow checked exception");
    }
}

However, even with rethrowing the exceptions, I was unable to get the desired behavior, ie logging the exception while still allowing Android to shutdown the component it had happened it, so I gave up on it after a while.然而,即使重新抛出异常,我也无法获得所需的行为,即在记录异常的同时仍然允许 Android 关闭发生它的组件,所以我在一段时间后放弃了它。

I see that the question is too old, and hope my answer is helpful for others having the same issue...我看到这个问题太老了,希望我的回答对其他有同样问题的人有所帮助......

Give Crashlytics a try.试试Crashlytics It will give indepth insight into all the crashes on all the devices having your application and send a notification to you through email..And the best part is its completely free to use..它将深入了解所有拥有您的应用程序的设备上的所有崩溃情况,并通过电子邮件向您发送通知......最好的部分是它完全免费使用..

Ok, well I looked at the provided samples from rrainn and Soonil, and I found a solution that does not mess up error handling.好吧,我查看了 rrainn 和 Soonil 提供的示例,我找到了一个不会弄乱错误处理的解决方案。

I modified the CustomExceptionHandler so it stores the original UncaughtExceptionHandler from the Thread we associate the new one.我修改了 CustomExceptionHandler 以便它存储来自我们关联新线程的原始 UncaughtExceptionHandler 。 At the end of the new "uncaughtException"- Method I just call the old function using the stored UncaughtExceptionHandler.在新的“uncaughtException” - 方法结束时,我只是使用存储的 UncaughtExceptionHandler 调用旧函数。

In the DefaultExceptionHandler class you need sth.在 DefaultExceptionHandler 类中,您需要某物。 like this:像这样:

public class DefaultExceptionHandler implements UncaughtExceptionHandler{
  private UncaughtExceptionHandler mDefaultExceptionHandler;

  //constructor
  public DefaultExceptionHandler(UncaughtExceptionHandler pDefaultExceptionHandler)
  {
       mDefaultExceptionHandler= pDefaultExceptionHandler;
  }
  public void uncaughtException(Thread t, Throwable e) {       
        //do some action like writing to file or upload somewhere         

        //call original handler  
        mStandardEH.uncaughtException(t, e);        

        // cleanup, don't know if really required
        t.getThreadGroup().destroy();
  }
}

With that modification on the code at http://code.google.com/p/android-remote-stacktrace you have a good working base for logging in the field to your webserver or to sd-card.通过对http://code.google.com/p/android-remote-stacktrace上的代码进行修改,您就有了一个很好的工作基础,可以在现场登录到您的网络服务器或 SD 卡。

Google Play Developers Console actually gives you the Stack traces from those apps that have crashed and had sent the reports, it has also a very good charts to help you see the information, see example below: Google Play Developers Console 实际上为您提供了那些崩溃并发送报告的应用程序的堆栈跟踪,它还有一个非常好的图表来帮助您查看信息,请参见下面的示例:

在此处输入图片说明

I've been using Crittercism for my Android and iOS apps -- heard about them on techcrunch.我一直在将Crittercism用于我的 Android 和 iOS 应用程序——在 techcrunch 上听说过它们。 Pretty happy with them so far!到目前为止对他们很满意!

I made my own version here : http://androidblogger.blogspot.com/2009/12/how-to-improve-your-application-crash.html我在这里制作了自己的版本: http : //androidblogger.blogspot.com/2009/12/how-to-improve-your-application-crash.html

It's basically the same thing, but I'm using a mail rather than a http connexion to send the report, and, more important, I added some informations like application version, OS version, Phone model, or avalaible memory to my report...基本上是一样的,但我使用邮件而不是 http 连接来发送报告,更重要的是,我在报告中添加了一些信息,如应用程序版本、操作系统版本、手机型号或可用内存。 .

use this to catch the exception details:使用它来捕获异常详细信息:

String stackTrace = Log.getStackTraceString(exception); 

store this in database and maintain the log.将其存储在数据库中并维护日志。

Now a days Firebase Crash reports are very popular and easier to use.现在,Firebase 崩溃报告非常流行且更易于使用。 Please refer following link for more information: Firebase Crash Reporting有关详细信息,请参阅以下链接: Firebase 崩溃报告

Hope it will help you.希望它会帮助你。

You can also use a whole (simple) service for it rather than only library.您还可以为它使用整个(简单)服务,而不仅仅是库。 Our company just released a service just for that: http://apphance.com .我们公司刚刚为此发布了一项服务: http : //apphance.com

It has a simple .jar library (for Android) that you add and integrate in 5 minutes and then the library gathers not only crash information but also logs from running application, as well as it lets your testers report problems straight from device - including the whole context (device rotation, whether it is connected to a wifi or not and more).它有一个简单的 .jar 库(适用于 Android),您可以在 5 分钟内添加和集成该库,然后该库不仅会收集崩溃信息,还会收集正在运行的应用程序的日志,还可以让您的测试人员直接从设备报告问题——包括整个上下文(设备旋转,是否连接到 wifi 等等)。 You can look at the logs using a very nice and useful web panel, where you can track sessions with your application, crashes, logs, statistics and more.您可以使用非常漂亮且有用的 Web 面板查看日志,您可以在其中跟踪与应用程序的会话、崩溃、日志、统计信息等。 The service is in closed beta test phase now, but you can request access and we give it to you very quickly.该服务现在处于封闭 Beta 测试阶段,但您可以请求访问权限,我们会很快将其提供给您。

Disclaimer: I am CTO of Polidea, and co-creator of the service.免责声明:我是 Polidea 的 CTO,也是该服务的共同创建者。

Thanks resources present in Stackoverflow in helping me to find this answer.感谢Stackoverflow中的资源帮助我找到这个答案。

You can find your remotely Android crash reports directly into your email .您可以直接在电子邮件中找到远程 Android 崩溃报告 remmember you have to put your email inside CustomExceptionHandler class .记住你必须把你的电子邮件放在 CustomExceptionHandler 类中

public static String sendErrorLogsTo = "tushar.pandey@virtualxcellence.com" ;

Steps required :所需步骤:

1st) in onCreate of your activity use this section of your code. 1st) 在您的活动的 onCreate 中使用您代码的这一部分。

    if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
        Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
    }   

2nd) use this overridden version of CustomExceptionHandler class of ( rrainn ), according to my phpscript. 2) 根据我的 phpscript,使用 ( rrainn ) 的 CustomExceptionHandler 类的这个覆盖版本。

package com.vxmobilecomm.activity;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.AsyncTask;
import android.util.Log;

public class CustomExceptionHandler implements UncaughtExceptionHandler {

    private UncaughtExceptionHandler defaultUEH;
    public static String sendErrorLogsTo = "tushar.pandey@virtualxcellence.com" ;

    Activity activity;

    public CustomExceptionHandler(Activity activity) {
        this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
        this.activity = activity;
    }

    public void uncaughtException(Thread t, Throwable e) {

        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);
        e.printStackTrace(printWriter);
        String stacktrace = result.toString();
        printWriter.close();
        String filename = "error" + System.nanoTime() + ".stacktrace";

        Log.e("Hi", "url != null");
        sendToServer(stacktrace, filename);

        StackTraceElement[] arr = e.getStackTrace();
        String report = e.toString() + "\n\n";
        report += "--------- Stack trace ---------\n\n";
        for (int i = 0; i < arr.length; i++) {
            report += "    " + arr[i].toString() + "\n";
        }
        report += "-------------------------------\n\n";

        report += "--------- Cause ---------\n\n";
        Throwable cause = e.getCause();
        if (cause != null) {
            report += cause.toString() + "\n\n";
            arr = cause.getStackTrace();
            for (int i = 0; i < arr.length; i++) {
                report += "    " + arr[i].toString() + "\n";
            }
        }
        report += "-------------------------------\n\n";

        defaultUEH.uncaughtException(t, e);
    }

    private void sendToServer(String stacktrace, String filename) {
        AsyncTaskClass async = new AsyncTaskClass(stacktrace, filename,
                getAppLable(activity));
        async.execute("");
    }

    public String getAppLable(Context pContext) {
        PackageManager lPackageManager = pContext.getPackageManager();
        ApplicationInfo lApplicationInfo = null;
        try {
            lApplicationInfo = lPackageManager.getApplicationInfo(
                    pContext.getApplicationInfo().packageName, 0);
        } catch (final NameNotFoundException e) {
        }
        return (String) (lApplicationInfo != null ? lPackageManager
                .getApplicationLabel(lApplicationInfo) : "Unknown");
    }

    public class AsyncTaskClass extends AsyncTask<String, String, InputStream> {
        InputStream is = null;
        String stacktrace;
        final String filename;
        String applicationName;

        AsyncTaskClass(final String stacktrace, final String filename,
                String applicationName) {
            this.applicationName = applicationName;
            this.stacktrace = stacktrace;
            this.filename = filename;
        }

        @Override
        protected InputStream doInBackground(String... params) 
        { 
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(
                    "http://suo-yang.com/books/sendErrorLog/sendErrorLogs.php?");

            Log.i("Error", stacktrace);

            try {
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
                        6);

                nameValuePairs.add(new BasicNameValuePair("data", stacktrace));
                nameValuePairs.add(new BasicNameValuePair("to",sendErrorLogsTo));
                nameValuePairs.add(new BasicNameValuePair("subject",applicationName));

                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                HttpResponse response = httpclient.execute(httppost);

                HttpEntity entity1 = response.getEntity();

                BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(
                        entity1);

                is = bufHttpEntity.getContent();

            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return is;
        }

        @Override
        protected void onPostExecute(InputStream result) {
            super.onPostExecute(result);

            Log.e("Stream Data", getStringFromInputStream(is));
        }
    }

    // convert InputStream to String
    private static String getStringFromInputStream(InputStream is) {

        BufferedReader br = null;
        StringBuilder sb = new StringBuilder();

        String line;
        try {

            br = new BufferedReader(new InputStreamReader(is));
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        return sb.toString();

    }
}

Google Firebase is Google's latest(2016) way to provide you with crash/error data on your phone. Google Firebase是 Google 最新(2016 年)为您提供手机崩溃/错误数据的方式。 Include it in your build.gradle file :将它包含在你的 build.gradle 文件中:

compile 'com.google.firebase:firebase-crash:9.0.0'

Fatal crashes are logged automatically without requiring user input and you can also log non-fatal crashes or other events like so :无需用户输入即可自动记录致命崩溃,您还可以记录非致命崩溃或其他事件,如下所示:

try
{

}
catch(Exception ex)
{
    FirebaseCrash.report(new Exception(ex.toString()));
}

There is this android library called Sherlock .有一个名为Sherlock 的android 库。 It gives you the full report of crash along with device and application information.它为您提供完整的崩溃报告以及设备和应用程序信息。 Whenever a crash occurs, it displays a notification in the notification bar and on clicking of the notification, it opens the crash details.每当发生崩溃时,它会在通知栏中显示通知,单击该通知时,它会打开崩溃详细信息。 You can also share crash details with others via email or other sharing options.您还可以通过电子邮件或其他共享选项与他人共享崩溃详细信息。

Installation安装

android {
    dataBinding {
      enabled = true
    }
}

compile('com.github.ajitsing:sherlock:1.0.0@aar') {
    transitive = true
}

Demo演示

在此处输入图片说明

There is a tool called fabric, this is a crash analytic tool, which will allow you to get crash reports , when application deployed live and during development.有一个叫做 fabric 的工具,这是一个崩溃分析工具,它可以让你在应用程序实时部署和开发过程中获得崩溃报告。 Adding this tool to your application was simple as well.. When your application crash that report of the crash can be viewed from your fabric.io dashboard .将此工具添加到您的应用程序也很简单。当您的应用程序崩溃时,可以从您的 fabric.io 仪表板查看崩溃报告。 thw report was catched automatically.it won't ask user for permission. thw 报告是自动捕获的。它不会请求用户许可。 Whether he/she want to send the bug/crash report.他/她是否要发送错误/崩溃报告。 And this is completely free... https://get.fabric.io/这是完全免费的... https://get.fabric.io/

While many of the answers on this page are useful, it is easy for them to become out of date.虽然此页面上的许多答案都很有用,但它们很容易过时。 The AppBrain website aggregates statistics which allow you to find the most popular crash reporting solution that is current: AppBrain 网站汇总了统计数据,让您可以找到当前最流行的崩溃报告解决方案:

Android crash reporting libraries Android 崩溃报告库

应用大脑网站

You can see that at the time of posting this picture, Crashlytics is used in 5.24% of apps and 12.38% of installs.您可以看到在发布此图片时,5.24% 的应用程序和 12.38% 的安装使用了 Crashlytics。

这是非常粗暴的,但是可以在任何地方运行 logcat,所以一个快速而肮脏的黑客是添加到任何 catch 块getRuntime().exec("logcat >> /sdcard/logcat.log");

We use our home-grown system inside the company and it serves us very well.我们在公司内部使用我们自己开发的系统,它非常适合我们。 It's an android library that send crash reports to server and server that receives reports and makes some analytics.它是一个 android 库,可将崩溃报告发送到服务器和服务器,后者接收报告并进行一些分析。 Server groups exceptions by exception name, stacktrace, message.服务器按异常名称、堆栈跟踪、消息对异常进行分组。 It helps to identify most critical issues that need to be fixed.它有助于识别需要修复的最关键问题。 Our service is in public beta now so everyone can try it.我们的服务现在处于公开测试阶段,所以每个人都可以尝试。 You can create account at http://watchcat.co or you can just take a look how it works using demo access http://watchcat.co/reports/index.php?demo .您可以在http://watchcat.co创建帐户,或者您可以使用演示访问http://watchcat.co/reports/index.php?demo来看看它是如何工作的。

If you want answers immediately you can use logcat如果你想立即得到答案,你可以使用logcat

$adb shell logcat -f /sdcard/logoutput.txt *:E

If there's too much junk in your log right now, try clearing it first.如果您的日志中现在有太多垃圾,请先尝试清除它。

$adb shell logcat -c

Then try running your app then logcat again.然后尝试运行您的应用程序,然后再次运行 logcat。

I found one more great web application to track the error reports.我发现了另一个很棒的 Web 应用程序来跟踪错误报告。

https://mint.splunk.com/ https://mint.splunk.com/

Small number of steps to configure.配置步骤少。

  1. Login or sign up and configure using the above link.使用上述链接登录或注册和配置。 Once you done creating a application they will provide a line to configure like below.完成创建应用程序后,他们将提供一行进行配置,如下所示。
 Mint.initAndStartSession(YourActivity.this, "api_key");
  1. Add the following in the application's build.gradl.在应用程序的 build.gradl 中添加以下内容。
 android { ... repositories { maven { url "https://mint.splunk.com/gradle/"} } ... } dependencies { ... compile "com.splunk.mint:mint:4.4.0" ... }
  1. Add the code which we copied above and add it to every activity.添加我们上面复制的代码并将其添加到每个活动中。

    Mint.initAndStartSession(YourActivity.this, "api_key"); Mint.initAndStartSession(YourActivity.this, "api_key");

That's it.就是这样。 You login and go to you application dashboard, you will get all the error reports.您登录并转到您的应用程序仪表板,您将获得所有错误报告。

Hope it helps someone.希望它可以帮助某人。

For an alternate crash reporting/exception tracking service check out Raygun.io - it's got a bunch of nice logic for handling Android crashes, including decent user experience when plugging it in to your app (two lines of code in your main Activity and a few lines of XML pasted into AndroidManifest).对于备用崩溃报告/异常跟踪服务,请查看Raygun.io - 它有很多很好的逻辑来处理 Android 崩溃,包括将其插入应用程序时的良好用户体验(主 Activity 中的两行代码和一些粘贴到 AndroidManifest 中的 XML 行)。

When your app crashes, it'll automatically grab the stack trace, environment data for hard/software, user tracking info, any custom data you specify etc. It posts it to the API asynchronously so no blocking of the UI thread, and caches it to disk if there's no network available.当您的应用程序崩溃时,它会自动获取堆栈跟踪、硬件/软件的环境数据、用户跟踪信息、您指定的任何自定义数据等。它异步将其发布到 API,因此不会阻塞 UI 线程,并缓存它如果没有可用的网络,请转到磁盘。

Disclaimer: I built the Android provider :)免责声明:我构建了 Android 提供程序 :)

Just Started to use ACRA https://github.com/ACRA/acra using Google Forms as backend and it's very easy to setup & use, it's the default.刚开始使用 ACRA https://github.com/ACRA/acra使用 Google 表单作为后端,设置和使用非常容易,这是默认设置。

BUT Sending reports to Google Forms are going to be deprecated (then removed):https://plus.google.com/118444843928759726538/posts/GTTgsrEQdN6 https://github.com/ACRA/acra/wiki/Notice-on-Google-Form-Spreadsheet-usage但是将不推荐使用(然后删除)向 Google 表单发送报告:https ://plus.google.com/118444843928759726538/posts/GTTgsrEQdN6 https://github.com/ACRA/acra/wiki/Notice-on-Google -Form-Spreadsheet-usage

Anyway it's possible to define your own sender https://github.com/ACRA/acra/wiki/AdvancedUsage#wiki-Implementing_your_own_sender you can give a try to email sender for example.无论如何,可以定义自己的发件人https://github.com/ACRA/acra/wiki/AdvancedUsage#wiki-Implementing_your_own_sender 例如,您可以尝试发送电子邮件。

With minimum effort it's possible to send reports to bugsense: http://www.bugsense.com/docs/android#acra只需最少的努力,就可以将报告发送到 bugsense: http : //www.bugsense.com/docs/android#acra

NB The bugsense free account is limited to 500 report/month注意bugsense 免费帐户限制为 500 报告/月

Late to the party, I support and believe ACRA is the best option among all.聚会迟到,我支持并相信 ACRA 是最好的选择。 Its easy to setup and configure.它易于设置和配置。 I have created a detailed guide with inputs from all over to fetch the crash report using ACRA and mail the same to my email address using MandrillAp.我创建了一个详细的指南,其中包含来自各地的输入,以使用 ACRA 获取崩溃报告,并使用 MandrillAp 将其邮寄到我的电子邮件地址。

Link to post: https://androidician.wordpress.com/2015/03/29/sending-crash-reports-with-acra-over-email-using-mandrill/帖子链接: https : //androidician.wordpress.com/2015/03/29/sending-crash-reports-with-acra-over-email-using-mandrill/

Link to sample project on github: https://github.com/ayushhgoyal/AcraSample github上的示例项目链接: https : //github.com/ayushhgoyal/AcraSample

I'm one of the founders of Bugsnag which we designed for exactly this purpose.我是Bugsnag的创始人之一,我们正是为此目的而设计的。 Bugsnag automatically captures unhandled exceptions in Android apps and sends them to our dashboard, where you can prioritize fixes and dive into diagnostic information. Bugsnag 会自动捕获 Android 应用程序中未处理的异常并将它们发送到我们的仪表板,您可以在那里优先修复并深入了解诊断信息。

Here are some important things to consider when selecting or building a crash reporting system, along with some code snippets:以下是选择或构建崩溃报告系统时需要考虑的一些重要事项,以及一些代码片段:

  • Detects unhandled exceptions automatically ( example code )自动检测未处理的异常( 示例代码
  • Collects diagnostic data such as memory usage, device info, etc ( example code )收集诊断数据,例如内存使用情况、设备信息等( 示例代码
  • Effectively groups crashes together by root cause按根本原因有效地将崩溃组合在一起
  • Allows you to track actions the user took before each crash to help reproduce ( example code )允许您跟踪用户在每次崩溃之前采取的操作以帮助重现( 示例代码

If you want to see some best practices around crash handling/reporting on Android you can check out the full source code for Bugsnag's crash reporting library which is fully open source, feel free to tear this apart and use it in your own applications!如果您想在 Android 上查看有关崩溃处理/报告的一些最佳实践,您可以查看完全开源的 Bugsnag崩溃报告库的完整源代码,请随意将其拆开并在您自己的应用程序中使用它!

Google changed how much crash reports you actually get. Google 更改了您实际获得的崩溃报告数量。 Previously you only got manual reported bug reports.以前,您只能收到手动报告的错误报告。

Since the last developer conference and the introducation of Android Vitals you also get crash reports from users which have enabled to share diagnostics data.自上次开发者大会和Android Vitals推出以来,您还可以从已启用共享诊断数据的用户那里获得崩溃报告。

You'll see all crashes collected from Android devices whose users have opted in to automatically share usage and diagnostics data.您将看到从用户选择自动共享使用情况和诊断数据的 Android 设备收集的所有崩溃。 Data is available for the previous two months.前两个月的数据是可用的。

View crashes & application not responding (ANR) errors 查看崩溃和应用程序无响应 (ANR) 错误

Flurry analytics gives you crash info, hardware model, android version and live app usage stats. Flurry 分析为您提供崩溃信息、硬件型号、Android 版本和实时应用程序使用统计信息。 In the new SDK they seem to provide more detailed crash info http://www.flurry.com/flurry-crash-analytics.html .在新的 SDK 中,他们似乎提供了更详细的崩溃信息http://www.flurry.com/flurry-crash-analytics.html

You can do this directly in Android Studio.您可以直接在 Android Studio 中执行此操作。 Just connect your phone, run the app, let it crash and you can view the stacktrace directly in Android Studio.只需连接您的手机,运行应用程序,让它崩溃,您就可以直接在 Android Studio 中查看堆栈跟踪。

If your app is being downloaded by other people and crashing on remote devices, you may want to look into an Android error reporting library (referenced in this SO post ).如果您的应用正在被其他人下载并在远程设备上崩溃,您可能需要查看 Android 错误报告库(在此 SO 帖子中引用)。 If it's just on your own local device, you can use LogCat.如果只是在您自己的本地设备上,则可以使用 LogCat。 Even if the device wasn't connected to a host machine when the crash occurred, connected the device and issuing an adb logcat command will download the entire logcat history (at least to the extent that it is buffered which is usually a loooot of log data, it's just not infinite).即使在崩溃发生时设备没有连接到主机,连接设备并发出 adb logcat 命令也会下载整个 logcat 历史记录(至少在缓冲的范围内,这通常是日志数据的loooot ,它只是不是无限的)。 Do either of those options answer your question?这些选项中的任何一个都回答您的问题吗? If not can you attempt to clarify what you're looking for a bit more?如果没有,您能否尝试进一步澄清您正在寻找的内容?

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

相关问题 如何仅针对我的库模块/包获取特定于包的崩溃报告/数据(在某些应用程序中通过gradle依赖关系实现) - How do I obtain package specific crash report/data only for my library module/package (implemented in some Application via gradle dependency) 如何从firebase中将此特定数据检索到我的android studio应用程序列表视图中? - How do I retrieve this specific data from firebase into my android studio application listview? 如何从AlertDialog获取setMultiChoiceItems项? - How do i obtain the setMultiChoiceItems items from my AlertDialog? 如何从我的应用程序获取系统信息? - how do i obtain system info from my app? 如何从Android上的Google Volley获得响应? - How do I obtain the response from google volley on Android? 如何从Android应用程序调用Servlet? - How do I invoke a servlet from my android application? 如何从Android上的应用程序启动URL? - How do I launch a URL from my application on Android? 如何在Android中获取以下布局 - How do I obtain the following layout in android 如何将Android测试库与Android Studio中的应用程序库分开? - How do I keep my Android testing libraries separate from my application libraries in Android Studio? 如何将 OTP 从我的服务器发送到我的 android 应用程序? - How do I send OTP from my server to my android application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM