Eclipse在异常时打开错误的源文件 [英] Eclipse opens wrong source file on exception

查看:153
本文介绍了Eclipse在异常时打开错误的源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse工作区中有几个Android项目:

I have several Android projects in an Eclipse workspace:


  • 一个独立的应用程序项目,一个类 my.package.Foo

  • 具有不同类的图书馆项目 my.package.Foo

  • 依赖于图书馆项目并且不包含源代码的两个应用程序项目

  • a stand-alone application project with a class my.package.Foo
  • a library project with a different class my.package.Foo
  • two application projects that depend on the library project and contain no source code

在使用构建在库项目之上的应用程序之一时,问题出在了。当它崩溃(可悲的是,频繁发生),我双击一行在logcat中的堆栈跟踪到相关的源。问题是,如果该行是针对 Foo.java ,Eclipse将始终从独立项目打开源代码。我可以将Eclipse直接导向到正确的源码,就是关闭独立的项目,这有点不方便。

The problem comes when working with one of the applications built on top of the library project. When it crashes (sadly, a frequent occurrence), I double-click on a line of the stack trace in the logcat to go to the relevant source. The problem is, if the line is for Foo.java, Eclipse always opens the source from the stand-alone project. The only way I can direct Eclipse to the right source is to close the stand-alone project, which is somewhat inconvenient.

有没有办法让Eclipse注意哪个应用程序在查找相关源文件时实际崩溃?我假设这是某种类路径问题(类似于这篇文章)。但是,我在Android运行配置属性中看不到任何修改类路径的内容。 Eclipse总是似乎按照名称按字母顺序运行工作空间项目,并打开它找到的第一个 my / package / Foo.java

Is there any way to get Eclipse to pay attention to which application actually crashed when it looks for the relevant source file? I assume that this is some sort of classpath problem (similar to that described in this post). However, I don't see anything in the Android run configuration properties for modifying the class path. Eclipse always seems to run through the workspace projects in alphabetical order by name and opens the first my/package/Foo.java it finds.

我正在使用最新的Android ADT和SDK版本。

I'm using the latest Android ADT and SDK versions.

推荐答案

根据评论中提供的链接通过@blessenm,这是Eclipse中的logcat问题。我们应该在第20版的SDK工具中看到一个修复。可以看到这里,修复它的补丁已经完成,是在线最终批准。

Per the link provided in the comment by @blessenm, this is an issue with logcat in Eclipse. We should see a fix in Release 20 of the SDK tools. As can be seen here, the patch that fixes it has been completed and is in line for final approval.

同时,最好的办法是更改logcat首选项(Window - > Preferences - > Android - > LogCat),以便双倍 - 单击操作是转到问题(方法声明),而不是默认的转到问题(错误行)。这不是万无一失的:它将至少打开文件,但是如果有多个具有相同名称的方法,则将转到第一种方法,而不管签名。 (当修复程序被合并时,不需要双击操作的选项,它将从偏好中消失。)

Meanwhile, the best thing to do is to change the logcat preferences (Window -> Preferences -> Android -> LogCat) so that the double-click action is "Go to Problem (method declaration)" instead of the default "Go to Problem (error line)". This isn't foolproof: it will at least open the file but if there are multiple methods with the same name, it will go to the first method, regardless of signature. (When the fix is incorporated, there will be no need for options for double-click action and it should disappear from the preferences.)

这篇关于Eclipse在异常时打开错误的源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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