Java.lang.RuntimeException: Stub! - Android code coverage?

I used the EclEmma coverage tool to check for code coverage. But whenever I run my test cases, it gives me the following error. Could you tell me how I can solve this error.

enter image description here

+6
source share
2 answers

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 

as I fixed, you need to move junit.jar before android.jar in the class path of my eclipse project. The reason is that both junit and android contain the same package and class for junit.runner.Version , so when android.ja r is ahead, the class loader will load this class from android.jar , but it should load it from junit.jar and thus throws an exception.

+5
source

I met a similar problem. It seems like this was because you added an Android project to the project, which is not an Android project. In my case, I am changing the project to an Android project, and it works well.

+1
source

Source: https://habr.com/ru/post/912704/


All Articles