10

我最近注意到,当发生未捕获的异常时,我的应用程序不会崩溃,但它没有响应。我使用谷歌分析来了解崩溃,我怀疑这可能是问题的原因。

当我投入NullPointerExceptiononCreate()紧接着super.onCreate())时,应用程序会显示一个白屏,但它不会崩溃。

Logcat 说:

06-30 14:00:59.386  26259-26259/? I/GAv4﹕ Google Analytics 7.5.71 is starting up. To enable debug logging on a device run:
    adb shell setprop log.tag.GAv4 DEBUG
    adb logcat -s GAv4
06-30 14:00:59.398  26259-26259/? W/GAv4﹕ AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See http://goo.gl/8Rd3yj for instructions.
06-30 14:00:59.409  26259-26259/? W/GAv4﹕ CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.
06-30 14:00:59.414  26259-26295/? W/GAv4﹕ AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See http://goo.gl/8Rd3yj for instructions.
06-30 14:00:59.467  26259-26259/? D/AndroidRuntime﹕ Shutting down VM

我想看看未捕获的异常,因为如果我看不到堆栈跟踪和问题的原因,真的很难修复它们。

我该怎么做才能恢复以前的行为?

编辑:删除分析错误报告(不调用tracker.enableExceptionReporting(true);)后,我再次遇到崩溃。我使用 Play Services 7.5.0 中的分析。

4

2 回答 2

1

谷歌分析是罪魁祸首。在开发时尝试禁用它(或禁用未捕获异常的自动报告),并在使用发布密钥签署应用程序时启用它。

于 2015-10-15T06:09:57.697 回答
-1

Exceptions默认情况下显示在控制台中。

如果您不想检查控制台(我认为为此目的更方便,因为Logcat有时会很混乱),那么只需Exception在被捕获时显示 s即可Log

try {

} catch (Exception e) {
    Log.e("YOUR_APP_TAG", "Exception occured: ", e);
}
于 2015-06-30T12:19:21.613 回答