简体   繁体   English

Android Robotium测试 - NoClassDefFoundError

[英]Android Robotium test - NoClassDefFoundError

I'm having problems with Robotium being unable to find my app at runtime. 我遇到了Robotium无法在运行时找到我的应用程序的问题。

Just to be clear, I've seen a few similar questions on SO however, they seem to revolve around the Robotium Solo class not being found at runtime (or some other 3rd party lib). 为了清楚起见,我在SO上看到了一些类似的问题,但它们似乎围绕着在运行时(或其他第三方lib)找不到的Robotium Solo类。 However, this is slightly different as my Robotium tests can't find the project under test . 但是,由于我的Robotium测试无法找到待测项目 ,因此略有不同。

The tests are in a separate project which has a dependency on my app project. 测试是在一个单独的项目中,它依赖于我的应用程序项目。 There are no problems at compile-time but when I try to run the tests I get... 在编译时没有问题,但是当我尝试运行测试时,我得到...

java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests 
....
Caused by: java.lang.NoClassDefFoundError: com.myapp.mobile.activity.RegisterUserScreen

Where RegisterUserScreen is an activity in my app. RegisterUserScreen是我的应用程序中的活动。 This happens on the device and the emulator. 这发生在设备和仿真器上。

I'm building / running in IntelliJ 12.1.4, against Android 4.1.2 and I see the same result when I attempt to run the test from the command line. 我正在使用IntelliJ 12.1.4构建/运行Android 4.1.2,当我尝试从命令行运行测试时,我看到相同的结果。

Probably worth pointing out that running adb shell pm list instrumentation from the command line returns the correct instrumentation... 可能值得指出的是,从命令行运行adb shell pm list instrumentation会返回正确的检测...

instrumentation:com.myapp.mobile.test.system/android.test.InstrumentationTestRunn
er (target=com.myapp.mobile)

Thanks in advance, 提前致谢,

Neil. 尼尔。

In your device go to settings->apps and check whether in installed or running application list name of your testing application name is present. 在您的设备中,转到settings-> apps并检查测试应用程序名称的已安装或正在运行的应用程序列表名称是否存在。 If you find it there then uninstall the testing app as well as your original app (which has to be tested). 如果你在那里找到它,那么卸载测试应用程序以及原始应用程序(必须进行测试)。 Many times it happens that either because of different versions/signature mismatch test-application fails to find the target application. 很多时候,由于不同版本/签名不匹配测试应用程序无法找到目标应用程序。

将您的运行配置创建为“Android测试”,而不是“JUnit”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM