12-28 12:33:26.790: D/AndroidRuntime(11175): Shutting down VM
12-28 12:33:26.790: W/dalvikvm(11175): threadid=1: thread exiting with uncaught exception (group=0x414c0930)
看不到具体的异常堆栈信息了。而看不到具体堆栈信息了
,解决Crash问题就非常困难了。
解决方式
创建一个自定义的Application类,在该类中定义一个静态属性来获取Android默认的 UncaughtExceptionHandler 。
public
static final UncaughtExceptionHandler sUncaughtExceptionHandler = Thread
.getDefaultUncaughtExceptionHandler();
然后在项目中所有Activity、Service 的onCreate函数中添加如下一句:
@Override
protected void onCreate(Bundle savedInstanceState) {
Thread.setDefaultUncaughtExceptionHandler(App.sUncaughtExceptionHandler);
,这样可以把Android默认的UncaughtExceptionHandler 给设置回来。
如果这样还是不行,那就在onResume函数中也设置一下。
这样就应该可以在LogCat中看到Crash Log。
本文介绍了一种解决Android应用崩溃(Crash)时无法获取到详细异常堆栈信息的方法。通过在Application类中设置默认的UncaughtExceptionHandler,可以在LogCat中捕获Crash日志。
1万+

被折叠的 条评论
为什么被折叠?



