Unable to Debug Library Projects with ADT v14 - Source Not Found

房东的猫 提交于 2019-12-04 08:53:20

问题


Ever since upgrading my current projects to use the new R14 Tools in Eclipse, I'm now unable to debug any code that exists in my library projects.

When I hit a break point in my library project code, instead of Eclipse opening the original source file, it opens up the read-only copy of the source file contained within the JAR with the message "Source not found".

I've searched around for a solution to this, but have yet to come across anything. Does anybody else have any suggestions? It's quite a pain not being able to debug.

EDIT

The issue has came back and I'm no longer able to debug. I haven't changed any project settings around or anything. Very frustrating.


回答1:


After having this issue as well and doing a little research, I came across this thread and another one that tipped me off. I was pulling my hair out already.

It turns out that the problem is with the build order of your projects (mine was anyway). Since ADT/SDK v14 changed the way library projects are referenced, the build order needs to be correct. Make sure all of the libraries your app uses are built first. I just moved the "src" and "gen" folders for each of my projects to the bottom and now it builds the library first and I am able to debug it and view the source of my library files through the main project.

In case someone doesn't know where to do this, in Eclipse, right click on your project and "Build Path" and then click "Configure Build Path". Then, on the "Order and Export" tab, move the two folders for your project to the bottom of the list below your libraries. I did this for all of my projects and the library projects.

You can also do it globally in Eclipse from Windows->Preferences->General->Workspace->Build Order and moving your library projects to the top. I think the build order defined in each project will override this though, so you may want to do it in both places to solve the issue now and for future projects.

I hope this is helpful to you and anyone else experiencing this annoying issue. :)

Thanks, Ed




回答2:


Tried all of the above and it did not work for me, however the workaround detailed here did.

http://code.google.com/p/android/issues/detail?id=20731

  1. Start debugging, and run until you hit a breakpoint (and precisely get a .class file instead of the .java you would like to have)
  2. Right click in the Debug view of the Debug perspective (for example on the call stack), and choose "Edit Source Lookup Path"
  3. Add all your projects above "Default", via "Add..." > "Java project" > "Select All"

(I'm using ADT 15.0.2 preview from http://tools.android.com/download)




回答3:


I had the same problem in a project today. The project consists of an app which has two library dependencies. I could not see code during debugging and when using auto-completion when overriding methods Eclipse was unable to deduce proper argument names.

First of all, the problem manifested itself by showing the the 'gen' folder was used as the one that contained the source. To check whether this is the same issue go to your app project, open the Android dependencies and have a look at the properties of the your library dependencies. Location path said /libraryprojectname/gen.

If this is also your problem then go to the 'Order and Export' tab of each library project and move the 'gen' item below the 'src' item. As soon as you click OK Eclipse will work a bit and when you check the Android dependency properties the location path should say: /libraryprojectname/src. Open click the dependency and open any class inside the jar. It should show the source.

I am using ADT plugin 20.0.3 with Android SDK Tools 20.0.3 and Android SDK Platform Tools 14.




回答4:


The following worked for me on Eclipse Juno:

In Project Properties/Java Build Path:

  • In the Projects tab, added my library projects.
  • In the Order and Export tab, moved my library projects to the top, and checked them

Not sure if it's relevant, but Android SDK tools is rev 20.0.3 and Android SDK platform tools is 14.

Good luck.




回答5:


I assume you are opeining library project and there you put brakepoint. Try this: On main project open Library Projects->[yourlibrary.jar]->[yourfile.class] from Package Explorer, and then in .class file put brakepoints. This works for me at least :)




回答6:


Sometimes this happens to me. Not sure about the reason but the way I solve is:

Remove the main project from eclipse. -- Closs Eclipse -- Delete the jar file in the library project -- Open Eclipse -- Wait for the library project to compile -- Import the main project




回答7:


This problem also occurs with release 21 of ADT inside Juno. As a workaround, in the "debug" view of the debug perspective (where you see threads and method invocation traces), right click and edit source lookup path.



来源:https://stackoverflow.com/questions/7899183/unable-to-debug-library-projects-with-adt-v14-source-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!