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


I'm trying to create a test fixture using Fitnesse framework, and I want to test a function which retrieves data from a server (RESTFUL service). My test case is very simple:

public class FriendListActivityFixture extends ColumnFixture {
    public int URL;
    public String test() {
    JSONArray array = JsonHelper.getJsonArrayFromUrl("");
    return array.toString();

public static JSONArray getJsonArrayFromUrl(String url) {
        InputStream input = null;
        String result = "";
        JSONArray jsonArray = null;
        try {
            HttpClient httpclient = CustomHttpClient.getHttpClient();
            HttpPost httppost = new HttpPost(url);
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            input = entity.getContent();
        catch (Exception e) {
            Log.e(TAG + ".getJsonArrayFromUrl(String url)", "Error in http connection " + e.toString()); 

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(input, "iso-8859-1"), 8);
            StringBuilder content = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                content.append(line + "\n");
            result = content.toString();
        catch (Exception e) {
            Log.e(TAG + ".getJsonArrayFromUrl(String url)", "Error parsing result " + e.toString());

        try {
            jsonArray = new JSONArray(result);
        catch (JSONException e) {
            Log.e(TAG + "getJsonArrayFromUrl(String url)", "Error converting data " + e.toString());
        return jsonArray;

And here is the Fitnesse test page:!path fitnesse.jar

!path C:\Program Files (x86)\Android\android-sdk\platforms\android-10\android.jar
!path C:\Users\chan\git\Spotr\Spotr\bin\classes


Since it's just a demo, my test might look a bit silly at the moment. Unfortunately, I keep getting these errors:

java.lang.RuntimeException: Stub!
    at android.util.Log.e(
    at com.csun.spotr.util.JsonHelper.getJsonArrayFromUrl(
    at com.csun.spotr.fitnesse.FriendListActivityFixture.test(
    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 fit.TypeAdapter.invoke(
    at fit.TypeAdapter.get(
    at fit.Fixture$CellComparator.compareCellToResult(
    at fit.Fixture$CellComparator.access$100(
    at fit.Fixture.compareCellToResult(
    at fit.Fixture.check(
    at fit.ColumnFixture.check(
    at fit.Binding$QueryBinding.doCell(
    at fit.ColumnFixture.doCell(
    at fit.Fixture.doCells(
    at fit.Fixture.doRow(
    at fit.ColumnFixture.doRow(
    at fit.Fixture.doRows(
    at fit.ColumnFixture.doRows(
    at fit.Fixture.doTable(
    at fit.Fixture.interpretTables(
    at fit.Fixture.doTables(
    at fit.FitServer.process(
    at fit.FitServer.main(

And I have no idea what is it telling me? I wrote other testing method like add(), substract(), everything worked fine. I wonder does this error involve running a long task on the main thread? Any idea?

Best Solution

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.