Java Android UIAutomator:setAsHorizontalList()抛出noSuchMethodError

Java Android UIAutomator:setAsHorizontalList()抛出noSuchMethodError,java,android,testing,nosuchmethoderror,android-uiautomator,Java,Android,Testing,Nosuchmethoderror,Android Uiautomator,我在三星galaxy SII上运行android版本4.1.2。我最近开始使用UIAutomator来测试我的用户界面。问题是,每次我尝试在手机上运行测试时,在UIScrollable对象上使用的setAsHorizontalList()方法上都不会出现任何方法错误。Eclipse能够识别该方法,并且不会给出编译错误 private void turnOffNetwork() throws UiObjectNotFoundException { getUiDevice()

我在三星galaxy SII上运行android版本4.1.2。我最近开始使用UIAutomator来测试我的用户界面。问题是,每次我尝试在手机上运行测试时,在UIScrollable对象上使用的setAsHorizontalList()方法上都不会出现任何方法错误。Eclipse能够识别该方法,并且不会给出编译错误

    private void turnOffNetwork() throws UiObjectNotFoundException {
        getUiDevice().pressHome();

        UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
        allAppsButton.clickAndWaitForNewWindow();
        UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
        appsTab.click();
        UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
        appViews.setAsHorizontalList();
        UiObject settingsApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), "Instellingen");

        settingsApp.clickAndWaitForNewWindow();

        UiObject switchObject = new UiObject(new UiSelector().className(android.widget.Switch.class.getName()));

        if (switchObject.isChecked()) {
            switchObject.click();
        }
    }

不幸的是,setAsHorizontalList()函数只能在4.2.2(API 17)设备上工作,不能在API 16上工作,您可以在模拟器或带有API 17的平板电脑上尝试。几天前,我经过艰苦的学习

您是否正在使用API 16版本的
uiautomator.jar
android.jar
?或者您正在使用API 17?@Commonware是否有一个解决方法使其在API 16上工作?