Eclipse skipping lines while debugging

android, debugging, eclipse, java

Solution

The problem is, that you can't decompile the class files to debug it. Because the lines of the decompiled files will differ to the original Java source code lines (imagine: the real source code has some comments and other things which will not be compiled into class files)!

So, if your Eclipse shows you the current debug line `42`, then it only tells you, that the debugger will present you the `42th` line of code in the class file. This won't match your decompiled java source file.

However, you could decompile the class files with the option add line numbers as comments. These line numbers in comments you can compare to the actual stacktrace line numbers. This could help you a little bit to imagine the issue.

edit: as Laurent B recommended, you will be able to realign the code with JD-Eclipse, see: http://mchr3k.github.io/jdeclipse-realign/

+1 for the comment! :)

edit2: You won't be able to decompile with line numbers if the class files are compiled with the flag -g:none:

-g:none Do not generate any debugging information.

So if this is the case: try to find the original source code of your jar file!

Problem

I am new to both java and eclipse, I have been trying to debug an android app on a device. It is a small project with a jar file reference. I read similar questions but they didn't help. What I need is to be able to debug the source codes of the jar file so I attached the source codes ( which I obtained using a decompiler ) and I am able to go into source codes of the library so I thought I did that correctly. But I can not succeed in debugging into these source codes; in debug mode it skipps breakpoints (only the ones in the source files which are attached to jar file) and when I try to 'step into code' it goes to random lines skips lines when debugging. I am using the latest versions of eclipse, android sdk and jdk. I don't know what causes this problem and I'd like to know. Thanks in advance, I hope I explained sufficiently.

Original source