gpt4 book ai didi

java - 在 Android Studio 项目中使用 htmlunit 时,没有 Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier 类型的静态字段实例

转载 作者:行者123 更新时间:2023-12-04 23:50:59 32 4
gpt4 key购买 nike

我在我的 Android Studio 项目中使用 htmlunit 2.36.0。我成功编译了 apk,但是当我尝试获取网页时出现了一些运行时错误。
之前,我收到以下错误:

java.lang.BootstrapMethodError: Exception from call site

但是我可以通过在 gradle 中添加这个来解决这个问题:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

但是,现在我面临另一个错误:
 java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes3.dex)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:151)
at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.buildSSLSocketFactory(HtmlUnitSSLConnectionSocketFactory.java:89)
at com.gargoylesoftware.htmlunit.HttpWebConnection.configureHttpsScheme(HttpWebConnection.java:635)
at com.gargoylesoftware.htmlunit.HttpWebConnection.createHttpClientBuilder(HttpWebConnection.java:558)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getHttpClientBuilder(HttpWebConnection.java:519)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:171)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1407)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1326)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:396)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:317)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:469)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:450)

显然,在它自己的类或其父类(super class)中没有 AllowAllHostnameVerifier 的静态字段实例。我不知道如何解决这个问题。

最佳答案

hc.apache.org记录:
AllowAllHostnameVerifier已弃用。 ( 4.4 ) 使用 NoopHostnameVerifier
如果您将依赖项的版本降级为 4.3 (2013~2015) 异常将得到解决。

implementation 'net.sourceforge.htmlunit:htmlunit:2.15'

关于java - 在 Android Studio 项目中使用 htmlunit 时,没有 Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier 类型的静态字段实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60423257/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com