htmlunit: ERROR in Android - NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier

Hi. Im sorry, but I’ve been trying to solve this problem for a while now and I really need help because this is frying by brain and eyes. So I would love to have some help.

The error:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: paulor.nutritiontrackerkotlin, PID: 25944
    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!classes2.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:670)
        at com.gargoylesoftware.htmlunit.HttpWebConnection.createHttpClientBuilder(HttpWebConnection.java:588)
        at com.gargoylesoftware.htmlunit.HttpWebConnection.getHttpClientBuilder(HttpWebConnection.java:544)
        at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:173)
        at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1597)
        at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1519)
        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:498)
        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:413)
        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:551)
        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:533)
        at paulor.nutritiontrackerkotlin.MainActivityViewModel.getFood(MainActivity.kt:97)
        at paulor.nutritiontrackerkotlin.fragments.HomeFragment.onCreateView$lambda-0(HomeFragment.kt:26)
        at paulor.nutritiontrackerkotlin.fragments.HomeFragment.$r8$lambda$oLhVoC0TON1oPmPiWZ-31sqsrqE(Unknown Source:0)
        at paulor.nutritiontrackerkotlin.fragments.HomeFragment$$ExternalSyntheticLambda0.onClick(Unknown Source:2)
        at android.view.View.performClick(View.java:6294)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1131)
        at android.view.View$PerformClick.run(View.java:24770)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
        ```

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Technically there is no difference and you can stay with the android version - it is exactly the same code as the ‘real’ htmlunit. But there is some flexibility you are loosing because the httpclient is (shaded) included in your jar file and no longer an separate jar. This might be a problem for some users.

Will close this issue for now and update the readme a bit.

If you like you can have a look at the htmlunit-android readme and report open questions or suggestions.

you have to add the snapshot repo and i just made a fix. Please use 2.58.0-SNAPSHOT