Justin k
Justin k

Reputation: 1104

java.lang.RuntimeException: Stub! - Android Code Coverage?

I was using EclEmma coverage tool to test my code coverage. But whenever I run my test cases, It gives me the following error. Can you please tell me how can I solve this error.

enter image description here

Upvotes: 6

Views: 4564

Answers (2)

topxebec
topxebec

Reputation: 1427

I have met similar problem. Seems like it was because you add a android Jar to your project which is not a Android project. In my case,I change my project to a Android project and it works well.

Upvotes: 1

tabor
tabor

Reputation: 51

i met a similar question:

java.lang.RuntimeException: Stub!

at junit.runner.Version.id(Version.java:5)
    at org.powermock.modules.junit4.PowerMockRunner.getJUnitVersion(PowerMockRunner.java:32)
    at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:27

the way I fixed it is to move junit.jar ahead of android.jar in the class path of my eclipse project. The reason is that both junit and android contains the same package and class for junit.runner.Version, so when android.jar is ahead, the class loader will load this class from android.jar but it should download it from junit.jar, and thus throwing the exception.

Upvotes: 5

Related Questions