Using Android library in eclipse and jumping to class files instead of source file that is within eclipse workspace

前端 未结 2 1758
情书的邮戳
情书的邮戳 2021-02-13 14:02

I found this bug http://code.google.com/p/android/issues/detail?id=20731 that is resolved but it did not fix this exactly, but I see in comments that this is mentioned there as

相关标签:
2条回答
  • 2021-02-13 14:21

    I had a similar problem - Open Declaration command would bring up the .class file instead of the .java file. My problem however was occurring when I would use Open Declaration in my Android app project to goto some source in my Android Library project. By following some instructions from a comment on this blog post Eclipse now takes me to the .java file (instead of the .class file) when I use the Open Declaration command.

    The instructions are:

    1. Right click on your project, select Properties
    2. Select Java Build Path page
    3. Select Order and Export tab
    4. Select each library project your project depends on, and use Top or Up to move it above the projects outputs. Eg. move all library projects to the top.

    That fixed the goto .java instead of .class file issue for me.

    (Unfortunately though, after making these changes, this issue appears (at least it did for me): Could not find Library.apk!)

    I then setup my workspace as you describe in your question (Android App depends on Android Library project depends on Java Library project) I find that Open Declaration is always taking me to .java files, so it all appears to be working ok in this respect.

    Refactoring

    I tried to refactor a method which is defined in a class in the Android Library. A popup with a "problem" of

    Binary references to a refactored element have been found. They will not be updated, which may lead to problems if you proceed.

    However after pressing Continue the refactoring took place without any issues.

    I then tried to refactor a method which is defined in a class in the Java Library. I didn't get any popups this time, and the refactoring worked.

    The java library aspect might just work these days because the bugs you guys mentioned have been fixed... (I am using Eclipse 4.2.0 with ADT 20.0.3). I thought I would add this answer however incase it helps someone out with issues of Open Declaration jumping to .class instead of .java file.

    0 讨论(0)
  • 2021-02-13 14:24

    I found solution. I have to create Android library from my java library as well and then include it as android library as well as Java library , Then I have to reorder build path export items so Android "Library Projects” are last . And well not much work, Now even rename refactoring works , with some warning but works :) , Well I am happy developer again.

    0 讨论(0)
提交回复
热议问题