[英]Why do I get a NoClassDefFoundError when running my test on an ActionBarActivity?
So I am using Robotium and my test class is extending the ActivityInstrumentationTestCase2
class. 所以我使用的是Robotium,我的测试类正在扩展
ActivityInstrumentationTestCase2
类。 I have imported the v7 support library in my main project and also in the test project as libraries. 我已经在我的主项目中导入了v7支持库,并在测试项目中导入了库。
Now what I don't understand is that the test class is working when I change the class under test to extend Activity
but when I change it to ActionBarActivity
it returns a NoClassDefFoundError
. 现在我不明白的是,当我更改测试中的类以扩展
Activity
时,测试类正在工作,但当我将其更改为ActionBarActivity
它返回NoClassDefFoundError
。
Am I missing anything? 我错过了什么吗?
Here is the Log I am getting 这是我得到的日志
04-11 21:32:16.551: E/dalvikvm(23925): Could not find class 'com.example.project.ActivityClass', referenced from method com.example.project.tests.ActivityClass.<init>
Ensure you export the v7 support library referenced in test project. 确保导出测试项目中引用的v7支持库。
Right click on the test project, properties->java build path->order and export tab. 右键单击测试项目,properties-> java build path-> order和export选项卡。
For an example see step 5 under "Setup" Section here: http://www.stevenmarkford.com/android-ui-testing-with-espresso-basics-tutorial/ (although this is showing how to export the espresso library the same would apply in this case) 有关示例,请参阅此处“设置”部分下的步骤5: http : //www.stevenmarkford.com/android-ui-testing-with-espresso-basics-tutorial/ (尽管这显示了如何导出espresso库相同适用于这种情况)
I think your library v7 app compat has an import problem. 我认为您的库v7 app compat存在导入问题。
Try this: 尝试这个:
Import support library as a project from "sdk/extras/android/support/v7/appcompat".
从
"sdk/extras/android/support/v7/appcompat".
导入支持库作为项目"sdk/extras/android/support/v7/appcompat".
Reference library in your project (for Eclipse, "Properties - Android - Add"
). 项目中的参考库(对于Eclipse,
"Properties - Android - Add"
)。
Build projects (for Eclipse, "Projects - Build All"
). 构建项目(对于Eclipse,
"Projects - Build All"
)。 Make sure, you have "android.support.v7.appcompat"
in your main project gen folder. 确保您的主项目gen文件夹中有
"android.support.v7.appcompat"
。
If it still doesn't solve your problem, restart eclipse and clean and rebuild project 如果它仍然无法解决您的问题,请重新启动eclipse并清理并重建项目
If the problem persists, remove the support library from you computer and redownload it and follow above mentioned steps. 如果问题仍然存在,请从您的计算机中删除支持库并重新下载并按照上述步骤操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.