I am trying to understand Android's current relationship to Apache http-client. I need to use a standard Java library which relies on org.apache.httpcomponents:httpclient:4.5.2
and it appears to be impossible on Android.
We can see that in Android M, support was removed for httpclient. And in Android P, the library was removed from the boot class path and is unavailable to apps without a manifest entry. I can also see that there is an official Apache Android port of httpclient which is a suitable direct replacement for 4.3.5.1 if you need a slightly more modern version of the library. And that there is even a third party port of 4.4.1.1 for apps with a modern target sdk.
My app's min sdk is 17, and target sdk is 28. So my first question is, would it actually be possible to kill any reference to the Android version of apache httpclient with a min sdk stuck at 17, and if not how can I replace that version with 4.5.2 which is inside the library.
My specific error is java.lang.NoSuchFieldError: org.apache.http.conn.ssl.AllowAllHostnameVerifier.INSTANCE
, and even though I have a target SDK of 28, Android is still finding and using a legacy AllowAllHostnameVerifier.java
class with no INSTANCE
field: