β

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

Drakeet的个人博客 192 阅读
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:


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

In your Application class:


public class ExampleApplication extends Application {

  @Override public void onCreate() {
    super.onCreate();
    CrashWoodpecker.fly().to(this);
  }
}

And in your AndroidManifest.xml file:


<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

作者:Drakeet的个人博客
平平凡凡的,追求优雅的代码

发表评论