HTMLUnit和Android:JAXP不兼容

时间:2011-10-01 16:16:43

标签: android htmlunit

尝试连接到“www.google.com”抛出一个简单的HTMLUnit HTMLUnit的WebClient类初始化因与android jaxp impl不兼容而失败:

    final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3);

    HtmlPage page1 = null;
    try {
        page1 = webClient.getPage("http://www.google.com/");
    } catch (FailingHttpStatusCodeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block

...

09-30 23:05:57.867:ERROR / AndroidRuntime(289):致命异常:主要 09-30 23:05:57.867:ERROR / AndroidRuntime(289):java.lang.RuntimeException:无法启动活动ComponentInfo {com.mygo / com.mygo.HTMLUnitActivity}:java.lang.IllegalStateException:方法'jsxGet_encoding'是找不到com.gargoylesoftware.htmlunit.javascript.host.css.CSSCharsetRule中的编码属性 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.app.ActivityThread.access $ 2300(ActivityThread.java:125) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:2033) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.os.Handler.dispatchMessage(Handler.java:99) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.os.Looper.loop(Looper.java:123) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.app.ActivityThread.main(ActivityThread.java:4627) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at java.lang.reflect.Method.invokeNative(Native Method) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at java.lang.reflect.Method.invoke(Method.java:521) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at dalvik.system.NativeStart.main(Native Method) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):引起:java.lang.IllegalStateException:在com.gargoylesoftware.htmlunit.javascript.host.css.CSSCharsetRule中找不到编码属性的方法'jsxGet_encoding' 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.addProperty(ClassConfiguration.java:109) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.parsePropertyElement(JavaScriptConfiguration.java:437) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.parseClassElement(JavaScriptConfiguration.java:384) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.buildUsageMap(JavaScriptConfiguration.java:312) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration。(JavaScriptConfiguration.java:147) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(JavaScriptConfiguration.java:237) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine。(JavaScriptEngine.java:117) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.WebClient.init(WebClient.java:215) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.gargoylesoftware.htmlunit.WebClient。(WebClient.java:189) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):at com.mygo.HTMLUnitActivity.onCreate(HTMLUnitActivity.java:22) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 09-30 23:05:57.867:ERROR / AndroidRuntime(289):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

  • 我应该降级htmlunit吗? (我正在使用2.9)。
  • 在Android SDK上使用htmlunit的任何其他解决方案?

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

我通过降级到htmlunit 2.8来解决问题