Error java.lang.RuntimeException: Stub! in Android with Fitnesse testing

You can fix this problem and test within your IDE really easily by using Roboelectric.

As dtmilano said, you can't run Android code on your laptop as is, but Roboelectric basically substitutes the actual method implementations for the stubs in Android.jar.

Two things to watch out for if you go with this solution:

  • Make sure that your JAR import is above the Android JAR in your dependencies list if using IntelliJ

  • It defaults to blocking HTTP requests under the assumption that you don't actually want to change the state of a server somewhere. You can, however, disable this quite easily: Roboelectric.getFakeHttpLayer().interceptHttpRequests(false);


android.jar contains only stub implementation of the classes. It provides the means for you app to build, once you have your APK you must run it on an android device or emulator.

If I'm not wrong you are trying to run on host's JVM.