Android API 23 - repackaging HttpClient 4.X

Denial of responsibility

  • I know that we should no longer use HttpClient on Android
  • In API 23 we can use useLibrary 'org.apache.http.legacy'

I would like to continue using HttpClient (I also support libraries and projects based on it), however with API 23 the classes are gone.

I didn’t go away with the useLibrary , but cannot be used for further development (classes are not autocompleted, everything is displayed as invalid code)

We also have the opportunity to use the HttpComponents provided by the Android plug-in HttpClient 4.3.5.1 , which, however, does not provide the classes / headers / interfaces that Android provides in API <22, so it compiles, but we are still unable to develop efficiently.

Is there a complete reformatting of the HttpClient library (even versions higher than 4.3 are preferable), which can be used further with target / compile-Sdk version 23?

The last full repack that I could find is https://code.google.com/p/httpclientandroidlib/ , which uses version 4.3.2

I also added a comment to the HC JIRA issue https://issues.apache.org/jira/browse/HTTPCLIENT-1632

This workaround is likely to be needed only until HttpClient 5.X is released, as it must have completely different package names.

+7
source share
1 answer

Well, to answer my own question, I put a project that will repackage and compose the HttpClient bundled with the HttpMime, HttpCore and HttpClient-Cache packages in a different namespace.

Version 4.3.3 currently introduced (synchronized with ASF HC 4.3.3 version)

https://github.com/smarek/httpclient-android

This is completely customizable, so changing the name or version of the package / artifact, customizing the assembly to your needs, etc. should not be a problem.

It is also published in Maven Central under the identifier cz.msebera.android:httpclient:4.3.3 , and all your import codes using org.apache.http must be ported (to use this library) to cz.msebera.android.httpclient

+4
source

All Articles