Skip to content Skip to sidebar Skip to footer

Called From Wrong Thread Exception In Robotium Testcase

I'm writing Testcase using Robotium for my android app which has multiple activities. The app implements Drawer in UI. But when solo opens drawer, it gives the exception Called Fro

Solution 1:

In you setUp():

mActivity = getActivity();

And in you test case add this:

mActivity.runOnUiThread(new Runnable() {
    publicvoidrun() {
        solo1.clickOnActionBarHomeButton();
    }
});

But the error should not appear when you use standart robotium methods. If this solution does not work for you, please share full stack trace here.

Solution 2:

There is a problem in the 4.3 version of Robotium runOnUiThread will not help.

As the associated bug report says it's fixed in Robotium 4.3.1 version.

Download it here.

If you keep the runOnUiThread code and upgrade the lib, you will have a much more explicit exception in the logcat:

E/AndroidRuntime(32201): java.lang.RuntimeException:
  This method can not be calledfrom the main application thread

Remove the runOnUiThread and it will be fine.

Post a Comment for "Called From Wrong Thread Exception In Robotium Testcase"