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

前端 未结 2 1759
情书的邮戳
情书的邮戳 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条回答
  •  闹比i
    闹比i (楼主)
    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.

提交回复
热议问题