Android 单元测试 - 分辨率和分辨率验证问题
我刚刚改变了我的 Android 项目的构建方式,并且我的单元测试不再工作...我收到类似
WARN/dalvikvm(575): VFY: unable to resolve static field X in .....
WARN/dalvikvm(575): VFY: unable to find class referenced in signature
这些错误仅来自我的单元测试的错误,其中定义的类甚至看不到定义的其他类单元测试。
之前,每个项目都有自己的目录,其中包含第 3 方 jar 文件的副本。我读到过,Dex 通过引用做了一些奇怪的事情,但一直无法弄清楚如何解决这个问题。有更好的方法吗?我很想看到一个大型 Android 工作区的示例,其中有多个项目、jar 引用等...
是否可以通过订单/导出调整来解决此问题?
该项目的结构如下:
- Eclipse Workspace(PROJECT_HOME 类路径变量)
- lib
- 第 3 方 jar
- android.jar
- Java 项目 A
- 在 PROJECT_HOME 中查找
- Java 项目 B
- 在 PROJECT_HOME 中查找
- 取决于项目 A
- Android 项目
- 取决于 A 和乙
- 在 PROJECT_HOME 中查找
- 在 PROJECT_HOME Android 测试项目
- 取决于 A、B、Android 项目
- 在 PROJECT_HOME 中查找
I just switched the way my Android project is being built and non of my unit tests work any more...I get errors like
WARN/dalvikvm(575): VFY: unable to resolve static field X in .....
WARN/dalvikvm(575): VFY: unable to find class referenced in signature
These errors only come from my Unit Tests, where classes defined in it can't even see other classes defined in the unit test.
Before each project had its own directory with copies of the 3rd party jar files. I've read around that Dex does weird things with references but haven't been able to figure out how to fix this problem. Is there a better way to do this? I would love to see an example of a large Android workspace where there are multiple projects, jar references, etc...
Is it possible to fix this with an Order/Export tweak ?
The project is structured like this:
- Eclipse Workspace (PROJECT_HOME classpath variable)
- lib
- 3rd-party jars
- android.jar
- Java Project A
- Looks in PROJECT_HOME
- Java Project B
- Looks in PROJECT_HOME
- Depends on project A
- Android Project
- Depends on A & B
- Looks in PROJECT_HOME
- Android Test Project
- Depends on A , B, Android Project
- Looks in PROJECT_HOME
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要在测试项目中包含第 3 方 jar。只需在被测项目中导出即可:项目属性->java构建路径->排序并导出。完成此操作后,您就可以进行清洁并且效果应该很好。
Do not include the 3rd party jar in the test project. Simply export it in the testee project: project properties->java build path->order and export. Once this is done, you'll be able to clean and it should work fine.