Android Eclipse 里面依赖工程无法关联源码解决方案

来源:互联网 发布:ps基线优化 编辑:程序博客网 时间:2024/05/17 02:32

http://www.tielaba.com/yidongkaifa/20130809/276.html


 问题现象:

        The JAR of this class file belongs to container 'Android Dependencies' which does not allow modifications to source attachments on its entries

        因为工程是多个library工程组成的,最近遇到该问题,比较妨碍源码跟踪。于是网上查了一下资料,已经解决了,这里分享一下解决方案。

        出现这种情况分两种场景:

        场景1:代码调试场景解决方案:

              Debug 视图下
              -》在调试的线程上 右键单击
              -》选择Edit Source Lookup Path
              -》选择Add
              -》选择Java Project
              选择相应的Project 进行OK确定即可
        场景2:F3跟踪代码场景解决方案:

              可以在libs下建立一个.properites文件,android-support-v4.jar -> android-support-v4.jar.properties里面可以加两个键值src:和doc:,然后刷新工程,或者close project然后open,再不行的话,就重启eclipse。

         例如:

         我的工程是:CcbApp

         我依赖的工程是:MobileExtApi 是一个Library工程。

         MobileExtApi打出来的jar包名称为:mobileextapi.jar

         那么在CcbApp的libs下面创建一个文件:mobileextapi.jar.properties, 文件内容如下:

         src=E:\\projects\\android-alipayclient2\\apps\\MobileExtApi\\src         

         最后,关闭CcbApp工程,再重新打开一次就搞定了。

    

         以下是E文原话:

         The source attachement in fixed for r20. If you have library projects you should see the source for those automatically.
As for the original issue in this bug: - if you want to manually reference libraries in your project, you need to make them exported. If the project is a library then project referencing your library willnot have access to those libraries. - adding them to libs/ is the way to have dependencies be automatically resolved when you have several libraries, all depending on 3rd party libs (some of which may be the same or may be conflicting with each other).
Source attachement: to work with the new dependency system, we need to put the source attachement outside of the eclipse config. Next to any jar files in libs/ simply put a .properties file (foo.jar -> foo.jar.properties). This properties file currently support two properties:
src: relative or absolute path to the source folder (or archive). doc: relative or absolute path to the javadoc.
The properties file is a standard Java properties file, using ISO 8859-1 character encoding.

0 0
原创粉丝点击