Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier when using htmlunit in Android Studio Project

Posted on November 11, 2022 By

Solution 1 :

Use the port for android:

https://github.com/HtmlUnit/htmlunit-android

Use this as the dependency:

implementation("net.sourceforge.htmlunit:htmlunit-android:2.63.0")

Solution 2 :

As hc.apache.org documented:

AllowAllHostnameVerifier Deprecated. (4.4) Use NoopHostnameVerifier

If you downgrade dependencies’s version to 4.3(2013~2015) exception will be resolved.

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

Problem :

I am using htmlunit 2.36.0 in my Android Studio Project. I successfully compiled the apk but I am getting some runtime errors when I try to get a webpage.
Before, I was getting the following error:

java.lang.BootstrapMethodError: Exception from call site

But I was able to fix the issue by adding this in the gradle:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

However, now I am facing another error:

 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)

Apparently, there is no static field instance of AllowAllHostnameVerifier in its own class or or its superclasses. I have no idea how to fix this.

Comments

Comment posted by A Farmanbar

@DeborahAnn The main problem is htmlunit. htmlunit 2.36.0 removed AllowAllHostnameVerifier

Comment posted by A Farmanbar

@DeborahAnn you can not use htmlunit 2.36.0 for lower versions of httpclient

Comment posted by DeborahAnn

Can we talk in chat?

Comment posted by DeborahAnn

By the way, it works only with

READ  [FIXED] java - App crashes after pressing a button - bluetooth arduino
Powered by Inline Related Posts
Android Tags:android, android-studio, htmlunit, java

Post navigation

Previous Post: [FIXED] java – How to solve debug issue
Next Post: [FIXED] android – How to solve setting up this payment problem – paypal

Related Posts

[FIXED] android – Managing a device for public usage and forbidding specific app usage Android
[FIXED] Android Studio unable to display version number on app Android
[FIXED] image – “Requested Bitrate is too small” – displaying JPEG2000 on Android Android
[FIXED] android – Androidx, how to know dependency format/string Android
[FIXED] Android chromecast: how to detect cast state on app start, before the app has been backgrounded? Android
[FIXED] android – NestedScrolling not working with gridView Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What are the main features of Islamic education?
  • Is the Jeep 4xe worth it?
  • How does the ringer work on cast iron?
  • What is the biggest size interior door?
  • Is blue raspberry an original Jolly Rancher flavor?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme