简体   繁体   English

当stacktrace仅在eclipse中显示本机方法时,如何查找导致错误的代码行

[英]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.

相关问题 为什么我的eclipse编辑器没有显示错误但是当我尝试运行该文件时,它显示“无法解析为类型”错误? - How come my eclipse editor shows no error but when I try to run the file, it shows “cannot be resolved to a type” error? 如何从Eclipse中的线程提取stacktrace? - How do I extract a stacktrace from threads in Eclipse? 如何获取特定Java代码行的stacktrace - How do I get stacktrace of a particular line of Java program 如何使用堆栈跟踪或反射找到方法的调用者? - How do I find the caller of a method using stacktrace or reflection? 我如何在java中将stacktrace添加到我的调试打印输出中 - How do I in java add a stacktrace to my debugging printout Struts 2错误处理 - 如何获取stackTrace和exception属性? - Struts 2 Error Handling - How do I get the stackTrace and exception attribute? 我怎么知道我的代码库是否有 java 8 方法 - how do I know if my code base has java 8 methods 如何将方法从JRuby调用到Java代码中? - How do i call methods from JRuby into my Java code? Eclipse格式化程序:如何在我的方法中对齐代码 - Eclipse formatter: how do I align the code in my method 无法获取导致错误的代码中的实际行 - Can not get the actual line in my code causing the error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM