Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android API 23 - HttpClient 4.X repackaged

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.

like image 772
Marek Sebera Avatar asked Aug 24 '15 09:08

Marek Sebera


People also ask

What happened to Apache HTTP client in Android SDK?

With the Android M SDK (API 23), Google removed the Apache HTTP Client library. It was deprecated since API 22, and Google recommanded to use HttpURLConnection instead since API 9.

What happened to HTTP client in Android 6?

With the Android M SDK (API 23), Google removed the Apache HTTP Client library. It was deprecated since API 22, and Google recommanded to use HttpURLConnection instead since API 9. While the classes are still bundled in Android 6 ROMs, it won’t be long until we see them completely go away.

What version of Android SDK is required for Jelly Bean?

Initial release. The system version is 4.3. Android SDK Platform-tools r18 or higher is required. Android SDK Tools 22.0.4 or higher is recommended. For details about the platform changes, see the Jelly Bean overview and Android 4.2 API changes.

What is the latest Android version for developers?

Android 7.0 (API level 24) For details about the platform changes, see Android 7.0 for developers. Revision 1 (August 2016) Android 6.0 (API level 23)


1 Answers

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

like image 116
Marek Sebera Avatar answered Oct 07 '22 19:10

Marek Sebera