开发者

How to properly debug Java (Android) using Eclipse?

I am having problems with debugging my code. One of my AsyncTasks throws a RuntimeException, but I don't know which line in my code is responsible for this. Since I am new to Eclipse and Java in general, all of this is rather confusing to me.

Eclipse's debugging window shows me that my AsyncTask has been suspended because of a RuntimeException. Below that, there are three lines which point out certain lines of code. However, those lines do not exist in my code which is why I do not know what causes my application to crash. Am I missing something essential about debugging in Java / Android?

These are the three lines which I am given, by the way:

ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1086  
ThreadP开发者_开发技巧oolExecutor$Worker.run() line: 561   
Thread.run() line: 1096 

How am I supposed to work with that? Help would be greatly appreciated.


in the ddms you can get the message related to the error, warning or other type of messages into the logcat window if you can't able to find the logcat in the ddms then go to the menu Window->Show View->logcat click on that and you'll be able to see the message now in the same ddms you also get the device window from that select the device for you can able to debug or get the message from that device into the logcat.

now check this way you can find your error detail into this logcat details


You're best using the logcat - this will show the stacktrace and the error raised. I've never had great success stepping through the code in DDMS but with the errrors shown in the logcat it's normally pretty easy to work out why the error was raised.

See Pratik's answer for opening the logcat if it isn't visible within Eclipse.


Rajeev got it right - when you set a breakpoint on an exception, the debugger will break on the line that throws it, not the line that catches it. In this way, you can see what is causing the exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜