Java 标记“”上的语法错误;getInstance";,此令牌后应为标识符

Java 标记“”上的语法错误;getInstance";,此令牌后应为标识符,java,android,automation,Java,Android,Automation,这条线上有多个标记 -标记“”上出现语法错误,应为{ -令牌“getInstance”上的语法错误,此令牌后应为标识符 private class CrashWatcher implements UiWatcher { public boolean checkForCondition() { UiObject crashButton = new UiObject( new UiSelector().textStartsWith("Unfor

这条线上有多个标记 -标记“”上出现语法错误,应为{ -令牌“getInstance”上的语法错误,此令牌后应为标识符

private class CrashWatcher implements UiWatcher {
    public boolean checkForCondition() {
        UiObject crashButton = new UiObject(
                new UiSelector().textStartsWith("Unfortunately,"));
        if (crashButton.exists()) {
            log("Found the OK dialog");
            UiObject okButton = new UiObject(new UiSelector().className(
                    "android.widget.Button").text("OK"));
            try {
                okButton.click();
            } catch (UiObjectNotFoundException e) {
                log("The chance of not having 'OK' button when the application crash is extremely less.");
                return false;
            }
        }
        return true;
    }
};

您发布的代码不包含错误中的代码。请发布所有代码。如果您看不到问题出在何处,请在代码编译之前注释掉代码。这将为您提供查找的线索。
UiDevice.getInstance().registerWatcher(CRASH_WATCHER_NAME, new UiWatcher());