[英]How do I find the line of my code causing an error when the stacktrace only shows native methods in eclipse
The short question is when using eclipse, how can I find out what line of my code triggered the error in cases where the stacktrace and debugger call stack don't reveal anything other than Android native methods. 简短的问题是,当使用eclipse时,如果stacktrace和debugger调用堆栈没有显示Android本地方法以外的其他内容,我该如何找出代码的哪一行触发了错误。
I have been trying for a while to debug a program and have hit a bit of a wall. 我已经尝试了一段时间来调试程序,并且遇到了一些麻烦。 To give some background on the problem , my Android App crashes when I rotate my screen and I get the following stack trace:
为了提供有关此问题的背景知识,当我旋转屏幕并获得以下堆栈跟踪时,我的Android应用程序崩溃了:
From this stack trace, I can see that there is a Class Cast exception where a LinearLayout is trying to be cast as a Textview. 从此堆栈跟踪中,我可以看到有一个Class Cast异常,其中LinearLayout试图转换为Textview。 What I don't know is where in the code this exception took place.
我不知道该异常在代码中的何处发生。 Towards the bottom of the stack trace, the cause is just being explained when it cuts off with a "...55 more".
在堆栈跟踪的底部,仅用“ ... 55 more”来说明原因。 So I started looking around for ways of extending the log cat and the only way I found only worked with extending the printStackTrace method on a caught exception.
因此,我开始四处寻找扩展日志猫的方法,并且发现唯一的方法仅适用于在捕获的异常上扩展printStackTrace方法。 My next attempt was to run this on the debugger and examine the call stack when the exception was thrown.
我的下一个尝试是在调试器上运行此命令,并在引发异常时检查调用堆栈。 What I found looked like this:
我发现的内容如下所示:
both the call stack and the stack trace show the calls of several Android native methods but neither show what line in my code invoked the method. 调用堆栈和堆栈跟踪都显示了几个Android本机方法的调用,但都未显示代码中的哪一行调用了该方法。 What I think is happening is that this code is being run from a handle or event queue.
我认为这是从句柄或事件队列运行此代码。 My question is in cases like this, is there a clever way to be able to tell what line of my code triggered this exception?
我的问题是在这种情况下,是否有一种聪明的方法可以判断我的代码的哪一行触发了此异常? Thanks in advance for help.
在此先感谢您的帮助。
The screen rotation fires the following activity delegate 屏幕旋转触发以下活动委托
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
}
You can start by debugging your activity state from this place. 您可以从此位置调试活动状态开始。 Just validate that all activity/fragment members are still available and nothing was released.
只需验证所有活动/片段成员仍然可用并且没有发布任何内容即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.