如何从我的Android应用程序中获得崩溃数据(至少堆栈跟踪)?至少在我自己的设备上工作时可以通过电缆检索,但理想的情况是,从我的应用程序在野外运行的任何实例中都可以,这样我就可以改进它,使它更可靠。


当前回答

谷歌Firebase是谷歌最新的(2016)方式,为您提供崩溃/错误数据在您的手机。 将它包含在您的构建中。Gradle文件:

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

致命崩溃会自动记录,不需要用户输入,你也可以记录非致命崩溃或其他事件,如下所示:

try
{

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

其他回答

我一直在Android和iOS应用中使用cratercism——我在techcrunch上听说过它们。到目前为止,他们都很满意!

刚开始使用ACRA https://github.com/ACRA/acra使用谷歌形式作为后端,它非常容易设置和使用,这是默认的。

但是发送报告到谷歌表单将被弃用(然后删除): https://plus.google.com/118444843928759726538/posts/GTTgsrEQdN6 https://github.com/ACRA/acra/wiki/Notice-on-Google-Form-Spreadsheet-usage

无论如何,可以定义自己的发件人 https://github.com/ACRA/acra/wiki/AdvancedUsage#wiki-Implementing_your_own_sender 例如,你可以试着给发件人发电子邮件。

用最少的努力就可以将报告发送到bugsense: http://www.bugsense.com/docs/android#acra

注意:无bug感知账号每月最多500个报告

可以使用Thread.setDefaultUncaughtExceptionHandler()处理这些异常,但是这似乎与Android处理异常的方法相混淆。我尝试使用这样的处理程序:

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");
    }
}

然而,即使重新抛出异常,我也无法获得所需的行为,即记录异常,同时仍然允许Android关闭组件,所以我在一段时间后放弃了它。

我还找到了一个更好的web应用程序来跟踪错误报告。

https://mint.splunk.com/

配置步骤少。

使用上面的链接登录或注册并配置。一旦你创建了一个应用程序,他们将提供如下所示的一行来配置。

Mint initAndStartSession (YourActivity。这“api_key”);

在应用程序的build.gradl中添加以下内容。

android { ... 存储库{ Maven {url "https://mint.splunk.com/gradle/"} } ... } 依赖关系{ ... 编译”com.splunk.mint:薄荷:4.4.0” ... }

添加上面复制的代码,并将其添加到每个活动中。 Mint.initAndStartSession (YourActivity。这个,”api_key”);

就是这样。你登录并进入应用程序仪表板,你会得到所有的错误报告。

希望它能帮助到别人。

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). If it's just on your own local device, you can use 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). Do either of those options answer your question? If not can you attempt to clarify what you're looking for a bit more?