简体   繁体   中英

Android Robotium test - NoClassDefFoundError

I'm having problems with Robotium being unable to find my app at runtime.

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). However, this is slightly different as my Robotium tests can't find the project under test .

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. 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.

Probably worth pointing out that running adb shell pm list instrumentation from the command line returns the correct 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. 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”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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