Eclipse的Andr​​oid的调试器 - 凡在我的code我才引起的异常? [英] Eclipse Android Debugger - Where in my code did I cause the exception?

查看:142
本文介绍了Eclipse的Andr​​oid的调试器 - 凡在我的code我才引起的异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

诚然,我的问题基本上是相同的,因为这一个,但它似乎已得到答复:

Admittedly, my question is basically the same as this one, but it seems to have been left unanswered:

<一个href="http://stackoverflow.com/questions/3513859/nullpointerexception-in-handlestopactivity-no-reference-to-my-$c$c-in-stack-tr">NullPointerException在handleStopActivity - 没有提到我的code的堆栈跟踪

下载Eclipse的太阳神,Android开发工具插件,和JDK全部上周内。我是瞎搞与一个应用程序我的设备上,运行在调试模式下,它意外终止。我意识到我造成了一个NullPointerException异常,问题本身不是问题很长时间。

Downloaded Eclipse Helios, Android Developer Tools Plugin, and the JDK all within the last week. I was messing around with an app on my device, ran it in Debug mode, and it unexpectedly terminated. I realized I had caused a NullPointerException and the problem itself was not an issue for very long.

什么是一个问题,但问题在于,调试器似乎无法在我的$ C $确定,其中C异常被抛出。堆栈跟踪没有引用我的code。

What is an issue, however, is that the debugger seems unable to identify where in my code the exception was thrown. The stack trace does not reference my code.

事实上,如果我把在的OnCreate()方法下面,我得到了同样的问题。

Indeed, if I put the following in the OnCreate() method, I get the same problem

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    //lI("onCreate()");  //A silly logging thing I messed around with

    Integer iDareYou = null;
    iDareYou.byteValue();

值得称许的是,Eclipse肯定警告我说,code是可能要炸毁在我的脸上。但是当我真正运行这个设备上,返回的堆栈跟踪如下:

Much to its credit, Eclipse certainly warns me that the code is likely to blow up in my face. But when I actually run this on my device, the stack trace returned is the following:

Thread [<1> main] (Suspended (exception RuntimeException))  
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2787  
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2803   
ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 135 
ActivityThread$H.handleMessage(Message) line: 2136  
ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
Looper.loop() line: 144 
ActivityThread.main(String[]) line: 4937    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 521  
ZygoteInit$MethodAndArgsCaller.run() line: 868  
ZygoteInit.main(String[]) line: 626 
NativeStart.main(String[]) line: not available [native method]  

我搜索周围一些答案,不幸的是我能与人的'为什么我的Andr​​oid应用程序导致NullPointerException异常的问题上来?多种。

I searched around for some answers and unfortunately all I could come up with were questions of the 'Why is my Android app causing a NullPointerException'? variety.

我希望能找出什么,我应该为了能够找到我的code,我产生异常的点做不同的....因为我敢肯定,这种能力会来方便在未来的某个时候!

I'm hoping to find out what I should be doing differently in order to be able to find the point in my code where I caused the exception.... because I'm sure this ability would come in handy at some point in the future!

将编辑此添加一些信息。作为第一个注释下提到,国家在调试器挂起线程不是应用程序的最终状态。 pressing'简历'几次移动过程中沿那里的过程实际上终止点,但遗憾的是没有任何帮助的堆栈跟踪显示在Eclipse / ADT调试窗口。 然而的,在这一点上的堆栈跟踪我粘贴上面的后跟的北角的堆栈跟踪的我的code中的第3个独特的行输出到LogCat中。我有previously看了看LogCat中有什么我可以使用,但最有可能是之前,我有pressed'简历'在调试器中移动的过程中这种状态。但不幸的是,做这种方式在我的code在实际的调试器从不显示NPE的堆栈跟踪。

Going to edit this to add some information. As the first comment below mentions, the state in which the debugger suspends the thread is not the 'final' state of the application. Pressing 'resume' a couple times moves the process along to the point where the process actually terminates, although unfortunately no helpful stack trace is displayed in the Eclipse/ADT Debug window. However, at this point the stack trace I pasted above Followed By the first 3 unique lines of the stack trace of the NPE in my code is output to LogCat. I had previously looked to see if LogCat had anything I could use, but most likely it was before I had pressed 'resume' in the debugger to move the process to this state. Unfortunately though, doing it this way never displays a stack trace of the NPE in my code in the actual debugger.

但这一消息未启用全是坏事 - 从右侧的变量窗口中的信息,我可以看到,有一个在线程的当前作用域的NPE,让本来至少可以给我一个线索,一个NPE是事情(当然还有LogCat中)。

But the news isnt all bad - from the information in the 'Variables' window on the right, I can see that there is an NPE in the thread's current scope, so that would at least give me a clue that an NPE is going on (and of course there is LogCat).

因此​​,基于在不同主题的建议,围绕我已经找到了最好的工作是增加一个捕获和未捕获的断点NullPointerException异常。当我这样做并重新启动,调试器显示NPE的堆栈跟踪,我的code和直移动编辑窗口的地方,我引起了NPE行了。

So based on a suggestion in a different topic, the best work around I've found is to add a "Caught and Uncaught" breakpoint for NullPointerException. When I do this and relaunch, the debugger displays the stack trace of the NPE in my code, and moves the edit window straight to the line where I caused the NPE.

目前,我相信这是因为NPE被抓(和presumably,再次抛出)的Andr​​oid框架。 看来原来的困境是由一个事实,即在Eclipse / ADT / DalvikVM调试堆栈跟踪窗口不包括信息'所致(据我可以告诉)引起的显示在堆栈跟踪后出现在LogCat中。我将进一步调查,这是否可以补救:)

At the moment I believe this is because the NPE is being caught (and presumably, thrown again) by the Android framework. It appears the original dilemma was caused by the fact that the Eclipse/ADT/DalvikVM Debug Stack Trace window does not include the 'caused by' information (as far as I can tell) that is displayed in the stack trace "later" appearing in LogCat. I will investigate further as to whether this can be remedied :)

我AP preciate伯特·F公司的建议,因为我没有完全意识到该线程尚未在其最终状态。虽然这是事实,堆栈跟踪是[后面]显示在LogCat中,我没有'小姐'是在LogCat中,因为它不是[但]有,我所做的小姐打'简历',这将导致堆栈跟踪要输出LogCat中。

I appreciate Bert F's suggestion, as I was not fully aware that the thread was not yet in its 'final' state. While it is true that the stack trace is [later] displayed in LogCat, I did not 'miss' it in LogCat because it was not [yet] there, what I did miss was hitting 'resume' which would have caused the stack trace to be output in LogCat.

尽管我最初得到了调试器在我的code线使用断点停下来,有一个事实,即我可以最终获得在LogCat中的堆栈跟踪恢复线程后,这将案件有效地解决了这个问题。唯一的其他东西我真的可以要求将有调试器停在该行中我code引起的异常,而不是它被捉住,后来重新抛出的Andr​​oid框架。但我相信,这将是一个不同的问题:)和Eclipse的,是有用的,因为它是会送我那里,如果我点击在LogCat中窗口中显示的堆栈跟踪相应的行。

Even though I originally got the debugger to stop at the line in my code using a breakpoint, there is a case for the fact that I could have ultimately obtained the stack trace in LogCat after resuming the thread, which would have effectively solved the problem. The only other thing I could really ask for would be to have the debugger stop at the line in my code causing the exception, instead of it being caught and later re-thrown by the Android framework. But I believe that would be a different question :) And Eclipse, being useful as it is, will send me there if I click on the appropriate line in the stack trace displayed in the LogCat window.

推荐答案

我跑你确切的code和LogCat中给了我以下情况除外:

I ran your exact code and LogCat gave me the following exceptions:

Caused by: java.lang.NullPointerException
    at mypackage.test.TestActivity.onCreate(TestActivity.java:23)

当然,这是

iDareYou.byteValue();

语句。这显然​​是一个阳光明媚的日子!

statement. This is clear as a bright day!

我建议你一定要学会如何使用的Dalvik调试监视器服务器在适当的方式。

I suggest that you must learn how to use Dalvik Debug Monitor Server in the proper way.

您发布的日志似乎pretty的没用,你搞砸了一些LogCat中滤波器(它发生在我身上一次)?

The log you posted seems pretty useless, did you messed up some of the LogCat filters(it happened to me once)?

OFFTOPIC:凡在我code我才引起的异常? - 我认为你的问题没有得到很好的制定。

OFFTOPIC: "Where in my code did I cause the exception?" - I think that your question is not well formulated.

我认为,这个问题的合适的名字可能会 - 如何使用Android的调试器和LogCat中?一些例外情况还没有登录正确!

I think that proper name of this question might be - 'How to use Android debugger and LogCat? Some exceptions are not logged properly!'

这篇关于Eclipse的Andr​​oid的调试器 - 凡在我的code我才引起的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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