Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change attached source in eclipse (android)

I am working on an Android project that depends on library written in Java. I develop the library too so I have sources of both - main project and library. I work with eclipse in standard way - both library and the main project are Android projects (no external jar in buildpath or something like that), both are open in the same workspace.

I have problem with debugging the library code. I can put a breakpoint there, the program really breaks but I do not see the source code (which is open in the next child window :-( ... ), I only see the class file editor of the correct file and Java pseudoassembler code. There is a button "Change attached source..." which looks potential but problem is that this button sometimes does not work. When I press it, I can choose "workspace..." or "external folder...", select src directory of the library and press ok, but this has no effect. There will be just a short progress dialog and no change.

Please note that sometimes "Change attached source..." works, but in general if it fails, the second (3rd, 4th, ...) will always fail to so trying it more times does not help. When "Change attached source..." takes effect, it works well for several eclipse sessions but then it fails again and repairing it by "Change attached source..." is a big lottery. Sometimes it works, sometimes not.

The problems are only with library code. The main project works always well even without explicit attached source settings.

Any idea?

"Change attached source..." button does never work. But there is (on the same place and in the same situation) sometimes other very similar button I think "Edit attached source..." (I am sure it starts with "Edit") and this button always works. It looks very wired but it really works so. It must be some bug in Eclipse or Android plugin.

like image 305
Jan Němec Avatar asked Oct 09 '22 13:10

Jan Němec


1 Answers

Finally I find the solution (tested on Eclipse Version: Juno Release, Build id: 20120614-1722 and Android SDK 20.0.3). When debugger stops on breakpoint in the "unknown" source of our library, right click on the stack line and it is possible to select an extra source folder in the context menu there. I always specify workspace folder and library src dir. This works in the latest Eclipse and Android SDK/ADT.

like image 190
Jan Němec Avatar answered Oct 12 '22 11:10

Jan Němec