Android API 23 - HttpClient 4.X repackaged

拈花ヽ惹草 提交于 2019-11-29 19:33:41

问题


Disclaimer

  • I know we shouldn't use HttpClient on Android anymore
  • In API 23 we have option to use useLibrary 'org.apache.http.legacy'

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

Well not gone with useLibrary workaround, but cannot be used to develop any further (classes don't autocomplete, everything is shown as invalid code)

We also have option to use HttpComponents provided Android fork of HttpClient 4.3.5.1, which however doesn't provide classes/headers/interfaces that Android provided on API < 22, so it compiles, but we're still unable to developer effectively.

Is there any full HttpClient library repackage (favorably even versions higher than 4.3) which can be used further with target/compile-Sdk of version 23 ?

Latest full repackage I could find is https://code.google.com/p/httpclientandroidlib/ which uses version 4.3.2

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

This workaround will be probably needed only until HttpClient 5.X will be released, as it should have completely different package names.


回答1:


Well, to answer my own question, I've put up project, which will repackage and build HttpClient in bundle with HttpMime, HttpCore and HttpClient-Cache packages into different namespace.

Currently the version provided is 4.3.3 (in sync with ASF HC 4.3.3 version)

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

It's quite customizable, so changing the package/artifact name or version, adjusting the build to your needs and so on should be no problem.

It's also published on Maven Central under identifier cz.msebera.android:httpclient:4.3.3 and all your code imports currently using org.apache.http should be migrated (for sake of using this library) to cz.msebera.android.httpclient



来源:https://stackoverflow.com/questions/32178854/android-api-23-httpclient-4-x-repackaged

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!