比 Logcat 更加美观易用的异常信息接收器: CrashWoodpecker

来源:互联网 发布:ubuntu 14使用教程 编辑:程序博客网 时间:2024/05/29 16:21
enframe_2015-09-02-17-51-03

因为我的 Android Studio 在使用的过程中, 经常会出现 App 崩溃了, 而 AS 自带的 logcat 并没有搜集到异常信息, 特别烦恼, 怎么折腾怎么重连都不痛快, 特别是对于那种 “启动崩” 的异常, 很难马上捕捉到, 丢失也是经常的.

所以我做了这么一个库, 仿造 Square 检测并展示内存泄露的 LeakCanary. 当开发过程中, 如果有没有处理的异常导致 crash, 使用了 CrashWoodpecker 以后, 便会起一个新的美观页面, 以很友好的方式即时展示异常信息. 更多内容可以参看一下我写在 GitHub 的文档:

CrashWoodpecker

An uncaught exception handler library like Square’s LeakCanary.

Getting started

NOTE: There is a big bug before VERSION 0.9.5, QAQ thank goodness, it has been fixed in version 0.9.5, please update to 0.9.5+.

In your build.gradle:

1
2
3
4
dependencies {
  debugCompile'me.drakeet.library:crashwoodpecker:0.9.7'
  releaseCompile'me.drakeet.library:crashwoodpecker-do-nothing:0.9.7'
}

In your Application class:

1
2
3
4
5
6
7
publicclass ExampleApplication extends Application {
 
  @Overridepublic void onCreate() {
    super.onCreate();
    CrashWoodpecker.fly().to(this);
  }
}

And in your AndroidManifest.xml file:

1
2
3
4
5
<application
    android:name=".ExampleApplication"// <--
    ...
    ...>
</application>

That is all! CrashWoodpecker will automatically show an Activity when your app crash with uncaught exceptions in your debug build.

7BDF054B-21AE-4A66-ACBF-6A51B1A0FA96

Demo apk download: LittleWood.apk

源代码: https://github.com/drakeet/CrashWoodpecker

0 0
原创粉丝点击