Thats Why No-One Will Remember Your Name

java.lang.RuntimeException: Stub! On With JUnit and Android

2. November 2011 10:35 by Scott in Development, Android  //  Tags: , , ,   //   Comments (34)

Running into another Error I figured I would blog about.

So im getting a Stub Error while trying to JUnit test a library I built with some Android code inside of it.  The Error is as follows:

java.lang.RuntimeException: Stub!
    at com.irad.conversion.gml.GmlConverter.GetAttributesFromGml(
    at com.irad.conversion.gml.GmlConverter.ConvertGmlPolygonToGraphic(
    at com.irad.conversion.gml.GmlConverter.ConvertGmlToEsriGraphic(
    at com.irad.conversion.gml.test.GmlConverterTest.ConvertGmlToEsriPolygonRingsGraphicTest(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(
    at org.junit.internal.runners.statements.RunBefores.evaluate(
    at org.junit.internal.runners.statements.RunAfters.evaluate(
    at org.junit.runners.ParentRunner.runLeaf(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.ParentRunner$
    at org.junit.runners.ParentRunner$1.schedule(
    at org.junit.runners.ParentRunner.runChildren(
    at org.junit.runners.ParentRunner.access$000(
    at org.junit.runners.ParentRunner$2.evaluate(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

While, I couldn't figure out what was going on, I kept getting a message of Stub while running some Android API code.  Keep in mind I was testing with JUnit outside of the official Android Test Project.  And in that lies the problem.


In order to run Android API code, you MUST run it on the emulator.  Which to me stinks and for something as easy as converting colors like I was feels needless, but I guess I must now convert all my JUnit tests to the Android JUnit Project Sadly.