Eclipse中的“Open Declaration”导航到类文件,而不是Android库的源文件

rqenqsqc  于 9个月前  发布在  Eclipse
关注(0)|答案(6)|浏览(150)

我有两个Android项目'A'和'B'。'B'依赖于'A',是一个库。每当我在项目'B'中点击'Open Declaration'来获取位于'A'中的Java源文件时,Eclipse就会导航到类文件而不是源文件。这当然有几个缺点!
我查看了项目B的构建路径,看看引用的库A是否有正确的路径到它的源项目,这是事实。
有人知道怎么修吗?
下面是每个项目的.classpath和project.properties文件:

**ProjectA .classpath

<?xml version="1.0" encoding="UTF-8"?>
  <classpath>
  <classpathentry kind="src" path="src"/>
  <classpathentry kind="src" path="gen"/>
  <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
  <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
  <classpathentry kind="output" path="bin/classes"/>
</classpath>

字符串

*项目A * 项目.properties

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8
android.library=true

**项目B .classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src"/>
  <classpathentry kind="src" path="gen"/>
  <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
  <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
  <classpathentry kind="output" path="bin/classes"/>
</classpath>

*项目B * 项目.properties

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8
android.library.reference.1=../ProjectA

iaqfqrcu

iaqfqrcu1#

您不仅可以将库项目导入为Android Lib(这是它的目的),还可以在通常的“Java Build Path”菜单中将其导入为链接项目。接下来,请确保将此导入移动到“Order and export”选项卡中的顶部(至少比“Library projects”条目更多)。
这工作,但它是一个黑客和它的肮脏.这不是它的意思是这样做.当你部署应用程序到手机,Eclipse将在控制台写一个错误消息说,一些apk无法找到.
尽管如此,我还是觉得链接到类文件更方便。
我不知道这是怎么回事。我办公室的朋友运行的配置和我一样,他们没有这个问题,但似乎我们不是唯一有这个问题的人:http://code.google.com/p/android/issues/detail?id=20731

f0brbegy

f0brbegy2#

当我的库项目A的版本在“Properties > Java Build Path > Libraries”中,而不是在“Properties > Java Build Path > Projects”中时,我也遇到了同样的问题。
问题在我做了以下操作后得到了解决:
1.从“Properties > Java Build Path > Libraries”中删除“Library Projects”,这是通过“Properties > Java Build Path > Libraries”添加的(我不确定这一步是否必要,但这是我所做的)。
1.将项目A添加到“Properties > Java Build Path > Projects”。
1.重新启动Eclipse(靛蓝)。Eclipse在“Properties > Java Build Path > Libraries”中重新创建了Library项目。
.classpath应该包含以下内容:

<classpathentry combineaccessrules="false" kind="src" path="/A"/>

字符串
实际上导航到类文件并不是最烦人的,但是在这个问题解决之前,在调试过程中打断类文件而不是java文件让我抓狂。

sirbozc5

sirbozc53#

我的做法是:将lib项目移到OrderExport选项卡下--主项目的/src/gen的正下方。

pnwntuvh

pnwntuvh4#

我的第一个猜测是你有一个包含A的类的目录,在B的构建路径上。检查Libraries选项卡。你能给我们看看你的.classpath和project.properties文件吗?

af7jpaap

af7jpaap5#

以下解决方案对我有效:
进入android library项目(在你的例子中,它是A)设置-> Java Build Path -> Order and Export,确保第一个条目是library的源文件夹(A)。然后清理library项目和目标项目。现在它工作得很好。

oknrviil

oknrviil6#

https://youtrack.jetbrains.com/issue/IDEA-309260https://stackoverflow.com/a/77576173/9633499的数据库
你可以切换注册表标志“编辑器.预览.标签.导航”.它为我工作.

相关问题