在Eclipse的开放宣言“导航到类文件,而不是为Android的库源文件 [英] 'Open Declaration' in Eclipse navigates to class files instead of to source files for Android Libraries

查看:116
本文介绍了在Eclipse的开放宣言“导航到类文件,而不是为Android的库源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个机器人项目A和B。 B依赖于A,是一个图书馆。每当我在项目B并点击打开宣言为它驻留在AJava源文件时,Eclipse导航到类文件,而不是源文件。这当然具有若干缺点!

我看了一下项目'B'的构建路径,以查看是否引用库中A具有正确的路径,它的源代码项目,它是这样的。

任何人知道如何解决这个问题?

下面是的.classpath和project.properties文件,每个项目:

项目A的的.classpath

 < XML版本=1.0编码=UTF-8&GT?;
  <类路径>
  < classpathentry KIND =SRC路径=SRC/>
  < classpathentry KIND =SRC路径=根/>
  < classpathentry KIND =CON路径=com.android.ide.eclipse.adt.ANDROID_FRAMEWORK/>
  < classpathentry KIND =CON路径=com.android.ide.eclipse.adt.LIBRARIES/>
  < classpathentry KIND =输出路径=斌/班/>
< /类路径>
 

项目A的 project.properties

 #此文件是由Android的工具自动生成的。
#不要修改这个文件 - 您所做的更改都将被删除!
#
#这个文件必须在版本控制系统进行检查。
#
#要自定义使用Ant构建系统的使用特性,
#ant.properties,并覆盖值,以适应脚本您
#项目结构。

#项目的目标。
目标=机器人-8
android.library =真
 

项目B的的.classpath

 < XML版本=1.0编码=UTF-8&GT?;
<类路径>
  < classpathentry KIND =SRC路径=SRC/>
  < classpathentry KIND =SRC路径=根/>
  < classpathentry KIND =CON路径=com.android.ide.eclipse.adt.ANDROID_FRAMEWORK/>
  < classpathentry KIND =CON路径=com.android.ide.eclipse.adt.LIBRARIES/>
  < classpathentry KIND =输出路径=斌/班/>
< /类路径>
 

项目B的 project.properties

 #此文件是由Android的工具自动生成的。
#不要修改这个文件 - 您所做的更改都将被删除!
#
#这个文件必须在版本控制系统进行检查。
#
#要自定义使用Ant构建系统的使用特性,
#ant.properties,并覆盖值,以适应脚本您
#项目结构。

#项目的目标。
目标=机器人-8
android.library.reference.1 = .. /项目A
 

解决方案

您可以导入库项目不仅是一个Android库(也就是它的意思做的方式),而且还因为在平时链接项目Java构建路径菜单。 其次,一定要此导入移动到顶部(至少多了库项目项)中的排序和导出选项卡。

这工作,但它是一个黑客,它是肮脏的。这不是它的目的是做的方式...当你部署应用程序到手机上,日食会写说在控制台中的错误信息,有些APK无法找到......

不过,我觉得更方便的链接到类文件。

我不知道这种情况正在发生。我在办公室里的哥们正在运行比我相同的配置,并且他们有没有这个问题,但似乎我们不是唯一的蒙山这个问题:<一href="http://$c$c.google.com/p/android/issues/detail?id=20731">http://$c$c.google.com/p/android/issues/detail?id=20731

I have two Android Projects 'A' and 'B'. 'B' depends on 'A' and is a Library. Whenever I'm in Project 'B' and hit 'Open Declaration' for a Java source file which resides in 'A', Eclipse navigates to the class file instead of the source file. This of course has several disadvantages!

I had a look at the build path of project 'B' to see if the referenced library 'A' has the correct path to it's source project which is the case.

Anyone knows how to fix that?

Here are the .classpath and project.properties files for each project:

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>

ProjectA project.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

ProjectB .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>

ProjectB project.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

解决方案

You can import the library project not only as an Android Lib (that is the way it's meant to be done), but also as a linked project in the usual "Java Build Path" menu. Next, be sure to move this import to the top (at least more that "Library projects" entry) in the "Order and export" tab.

This works, but it a hack and it's dirty. This is not the way it is meant to be done... and when you deploy the app to the phone, eclipse will write a error message in the console saying that some apk cannot be found...

Still, I find it more convenient that linking to the class file.

I don't know what this is happening. My buddies in the office are running the same configuration than me, and they have not this issue, but it seems we are not the only ones whith this problem: http://code.google.com/p/android/issues/detail?id=20731

这篇关于在Eclipse的开放宣言“导航到类文件,而不是为Android的库源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆