When I\'m debugging my code in Eclipse, I get annoyed when I open up the editor to find out I cant edit it because I\'m actually viewing the source of the .class file. How
For some reason Eclipse does not believe that the class file comes from your Java file. This is frequently a malconfigured buildpath, or a jar-file used instead of the project generating the jar file.
Look in the project manager panel (<->
button) to see where Eclipse finds the class file and then figure out why it uses that location instead of your project with the source file.
OK, so I hate to be "that guy", given the number of people for whom this worked, but this didn't work at all for me. I mean that the "Edit Source Lookup..." menu item was not in the context menu. I did not miss the instruction to do this in the Debug Perspective (presumably in the Project Explorer in the Debug Perspective). I tried it while the app was running and while the app was suspended. I tried checking the menu for the application's project (presumably what the instructions refer to) and for the library's project. No dice. This is with the latest Eclipse build.
However, I was able to resolve the issue:
main project properties -> Java Build Path -> Projects
tab and add there projects the main project depend on.Order and Export
tab and uncheck Android Dependencies
After I finally found some time and good reason to look into this issue a bit deeper I'll elaborate a bit on Thornbjorn's answer.
As of lately, Google changed the way your Android projects package your external Android libraries. In ADT R17 (I think) it started packaging the external projects source into .jar files and including them directly into your project in the Android Dependencies or /libs folder.
Now, when the debugger hits a breakpoint, it brings up your source code in the .jar, essentially telling you to edit a .class file. The problem is that this file is read-only and so you have to go find your .java source manually. (Pain)
The fix is to right click the Project name in the debug view, and select "Edit Source Lookup..." from the menu. From there, remove the Default lookup path. After that, manually add the associated projects (not jars) that your project references. This is done by clicking Add, selecting Java Project, then checking the appropriate projects.