如何在Eclipse调试器中看到崩溃的原因 [英] How to see the crash reason in Eclipse debugger

查看:191
本文介绍了如何在Eclipse调试器中看到崩溃的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循此Android教程: http://developer.android.com/resources /tutorials/hello-world.html 我添加了两行,这应该导致空指针异常:

Following this Android tutorial: http://developer.android.com/resources/tutorials/hello-world.html I added two lines which should cause null pointer exception:


Object o = null;
o.toString();

现在我在第二行设置断点并启动调试器。当调试器中断时,我点击转过来,应用程序崩溃。但是,我在调试器中没有看到任何有用的信息。调试窗口显示ActivityThread.performLaunchActivity,源窗口显示找不到源。在任何Eclipse调试器窗口中,我没有看到有关异常,空指针等的任何信息,并没有看到任何指向我的代码行导致崩溃的东西。那么,我失踪了什么?

Now I set breakpoint on the second line and start debugger. When debugger breaks, I click "Step over" and application crashes. However, I don't see any useful information in the debugger. Debug window shows ActivityThread.performLaunchActivity, Source window shows "No source found". I don't see any information about exception, null pointer, etc. in any Eclipse debugger window, and don't see anything pointing to my line of code that causes crash. So, what am I missing?

修改。也许Android UI框架有自己的异常处理机制,这阻止我在我的代码中立即看到异常?这样的事情发生在另一个UI框架,如WinForms,Qt,wxWidgets。

Edit. Maybe Android UI framework has its own exception handling mechanizm, which prevents me to see exception immediately in my code? Something like this happens in another UI frameworks, like WinForms, Qt, wxWidgets.

推荐答案

异常发生后,您应该检查Logcat窗口细节:在那里你会发现整个堆栈导致代码行的异常。在某些情况下,某些其他类(不是您的)会出现异常,那么您应该在堆栈中查找您的包/类名称来查找otu是否对此负责。

After exception occurs you should check Logcat window for details: there you find the entire stack leading to the line of code where exception is. In some cases exception will occur in some other class (not yours) - then you should look for your package/class name in the stack to find otu whether you're "responsible" for it.

相应的输出不会立即出现在Logcat中 - 让它运行一段时间(或直到它崩溃)。

Corresponding output will not appear in Logcat immediately - let it run for some time (or until it crashes).

还可以设置Java异常断点,所以当有异常时,执行会中断。

Also you can set "Java exception breakpoint" so the execution will break whenever there is an exception.

这篇关于如何在Eclipse调试器中看到崩溃的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆