@Override
    public boolean onJsAlert(WebView view, String url, String message, JsResult jsResult) {
      if (message != null && message.startsWith("selendroid<")) {
        jsResult.confirm();

        synchronized (syncObject) {
          String res = message.replaceFirst("selendroid<", "");
          int i = res.indexOf(">:");
          String enc = res.substring(0, i);
          res = res.substring(i + 2);

          /* Workaround for Japanese character encodings: Replace U+00A5 with backslash so that we
           * can properly parse JSON strings contains backslash escapes, since WebKit maps 0x5C
           * (used for character escaping in all of the Japanses character encodings) to U+00A5 (YEN
           * SIGN) and breaks escape characters.
           */
          if (("EUC-JP".equals(enc) || "Shift_JIS".equals(enc) || "ISO-2022-JP".equals(enc))
              && res.contains("\u00a5")) {
            SelendroidLogger.info("Perform workaround for japanese character encodings");
            SelendroidLogger.debug("Original String: " + res);
            res = res.replace("\u00a5", "\\");
            SelendroidLogger.debug("Replaced result: " + res);
          }
          result = res;
          syncObject.notify();
        }

        return true;
      } else {
        currentAlertMessage.add(message == null ? "null" : message);
        SelendroidLogger.info("new alert message: " + message);
        return super.onJsAlert(view, url, message, jsResult);
      }
    }
Unconventional way of adding a Javascript interface but the main reason why I took this way
is that it is working stable compared to the webview.addJavascriptInterface way.
selendroid-server/src/main/java/io/selendroid/server/model/SelendroidWebDriver.java