Android Eclipse 库项目和项目特定配置文件的库项目类型解析
我有几个 Android 项目共享我的库项目之一。我想让库代码依赖于某些配置类,这些配置类在依赖它的项目中定义不同。为了使非 lib 项目在 Eclipse 项目资源管理器中不报告错误,这意味着在每个项目中提供具有相同完全限定路径的类定义。
所以结构看起来像这样
Tablet_Project:
defines com.mycompany.config.ClientPrefs.java
Phone_Project:
defines com .mycompany.config.ClientPrefs.java
Lib_Project:
依赖但不定义 com.mycompany.config.ClientPrefs.java
一旦完成此操作,项目在 Eclipse 项目资源管理器中没有显示任何错误,但该库有一个红色的“X”,表明它可以解析 ClientPrefs 引用 - 这是我所期望的,因为无论如何你都无法编译库,所以看起来没什么大不了的。
问题:手机项目编译并运行良好,但平板电脑项目报告在启动之前需要修复错误,即使其工作区资源管理器中的任何位置都没有“X”指示符。
问题:这种配置方法实际上在这些项目中是允许的,还是电话项目的运行只是一个意外?
编辑 这是我能想到的最基本的例子:
ProjectA 和 ProjectB 依赖于 ProjectLib 作为 Android 库项目。如此处所示,ProjectLib 的 Util.java 无法解析对 Config.java 缺少的引用,但这对于 A 和 B 来说似乎并不重要,因为它们似乎为 ProjectLib 解决了这个问题,从而构建和运行。还有其他人采用这种方法进行配置吗?
我问的原因是因为我有一组更大的项目,其中一个项目将不再构建(在 Eclipse 中),大概是因为它的 lib 项目有错误。从命令行使用 Ant 构建总是有效,这让我认为库项目会被拉入依赖项目,而不考虑它的 Eclipse 边界。
I've got several android projects that share one of my library projects. I want to have the library code depend on certain configuration classes that are defined differently in the project(s) that are depending on it. In order to get the non-lib projects to report no errors in Eclipse project explorer, this means providing class definitions in each project with the same fully-qualified path.
So the structure looks like this
Tablet_Project:
defines com.mycompany.config.ClientPrefs.java
Phone_Project:
defines com.mycompany.config.ClientPrefs.java
Lib_Project:
depends on but does not define com.mycompany.config.ClientPrefs.java
Once this done, the projects show no errors in Eclipse project explorer, but the lib has a red "X" indicating that it can resolve the ClientPrefs reference - which I would expect, Since you can't compile a lib anyway it doesn't seem like a big deal.
Problem: The phone project compiles and runs fine, but the tablet project reports that an error needs to be fixed before launching even though there are no "X" indicators anywhere in its workspace explorer.
Question: Is this approach to configuration actually permissible in these projects or is the fact that the phone project works just an accident?
Edit
Here is the most basic example I can come up with:
ProjectA and ProjectB depend on ProjectLib as an Android Library project. As displayed here, ProjectLib's Util.java can't resolve the missing ref to Config.java but this doesn't seem to matter for A and B since they seem to resolve this for ProjectLib and thus both build and run. Anyone else taken this approach to config?
The reason I ask is because I have a much larger set of projects, and one of them won't build anymore (in Eclipse) presumably since it's lib project has errors. Building with Ant from the command line always works and that makes me think that a library project gets pulled into the dependent project without regard to it's Eclipse boundary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
之前可以在 ProjectA 和 ProjectB 中创建相同的 Config 类,并从 lib 项目中排除 Config 类。
但是现在库项目被包含为jar,并且无法在eclipse中从jar中排除类。
我的临时解决方案是使用 config util 类,它返回正确的配置,每次构建不同的项目时我都需要更改它。
Before it was possible to make the same Config class in the ProjectA and ProjectB, and exclude the Config class from lib project.
But now the library project is included as jar, and it is not possible to exclude class from jar in eclipse.
My temporary solution to have config util class, which returns the correct Config, I need to change it each time when build different project.