引用 Android 自定义库导致应用程序中找不到运行时类错误
我正在开发一个自定义 Android 库。我从一个 java 项目(在 Eclipse 中)和另一个 UI 测试 Android 项目开始。
在我的 UI 测试项目中,我在构建路径中引用了库项目,一切都很好,我可以在 UI 中测试库代码。
后来,我决定需要“Gen”代码(用于自定义样式属性),因此我尝试将我的库更改为 Android 项目(通过 Android-tools -> Convert.. ),但灾难发生了!解决了所有编译时问题后,它终于“让”我启动了 UI 测试应用程序,然后一声巨响!当我尝试从库类创建任何对象时,它(在日志中)说找不到类。
两个问题:
知道如何解决这个问题吗?我尝试过,但似乎它是为了引用另一个需要单独安装的 .apk。
如果我只是将其保留为我的库的 java 项目(而不是 android),我可以使用资源生成器吗?如何?
PS:根据Eclipse的控制台所说,依赖项(我的库)是在UI测试应用程序之前安装的。
更新:我尝试将库项目编译为 jar 并从 UI 测试中引用它,这样,它就可以工作了。但我不想使用这种方法,因为它在测试方面非常慢。
I am working on a custom Android library. I start off with a java project (in Eclipse) with another UI testing Android project.
In my UI testing project, I reference the library project in build path, and everything is good and I can test the library codes in the UI.
Later on, I decided I need to have the 'Gen' code (for custom styles attributes), so I try to change my library to an Android project (via Android-tools -> convert.. ), and disasters happens! After fixing up all the compile time problems, it finally 'let' me start the UI testing application, and bangs! When I try to create any objects from the library class, it said (in the Log) that Class not found.
Two questions:
Any idea how to fix this? I tried but seems it is for referencing another .apk that need to install separately.
If I just keep it to be java project (not android) for my library, can I use the resource generator? and how?
PS: the dependency (my library) is installed before the UI test application, according to the Console of Eclipse said.
Update: I tried to compile the library project to jar and reference it from the UI testing, and in this way, it works. But I don't want to use this approach since it is very slow in terms of testing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于那些像我一样犯同样错误的人
当库项目是一个 android 项目时,
必须
并添加项目,而不是
稍后的方法仅适用于纯java项目。
for those who are doing same mistake like me
when library project is an android project
got to
and add project, instead of
later approach is for pure java projects only .
最后我找到了我自己问题的答案。这实际上在官方文档中提到过。
Finally I found the answer to my own question. This is actually mentioned in official documentation.