httpclientandroidlib


Apache's HttpClient 4.3 repackaged for Android

Introduction

This is a repackaging of HttpClient 4.3.1 for Android. The version of HttpClient in the Android SDK is 4.0beta2. There have been several updates to HttpClient and some much-needed bugfixes like auth caching since the 4.0beta.

Since Google has deprecated HttpClient in favor of Java standard HttpURLConnection I created a script to convert
a stock release of Apache's HttpClient into an Android
library.

Get official Android port from Apache

An official Android port from Apache was released here:
https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html'>https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html
It's also available on Maven Central

Updates

22nd February 2014
1.2.1: Upgraded to HttpClient 4.3.2 and HttpCore 4.3.2
Downloads:
https://drive.google.com/file/d/0BzK7b0m5WJsfSktseFNvX09wVms/edit?usp=sharing'>https://drive.google.com/file/d/0BzK7b0m5WJsfSktseFNvX09wVms/edit?usp=sharing
https://drive.google.com/file/d/0BzK7b0m5WJsfZDNOVnlhVmhzTFk/edit?usp=sharing'>https://drive.google.com/file/d/0BzK7b0m5WJsfZDNOVnlhVmhzTFk/edit?usp=sharing

16th January 2014
1.2.0: Upgraded to HttpClient 4.3.1 and HttpCore 4.3.1
Better late than never! :) Thanks go to Christian H. for updating the script.

1st March 2013
1.1.2: Upgraded to HttpClient 4.2.3 and HttpCore 4.2.3

11th July 2012
1.1.1: Upgraded to HttpClient 4.2.1 and HttpCore 4.2.1
SPNego and Kerberos authentication were removed because of dependencies on org.ietf.jgss

9th May 2012
1.1.0: Upgraded to HttpCore 4.2
Be aware of incompatibilities to HttpCore 4.1.4, see http://www.apache.org/dist/httpcomponents/httpcore/RELEASE_NOTES.txt'>Release Notes

27th March 2012
1.0.4: Added HttpMime
Upgraded to HttpClient 4.1.3

14th February 2012
1.0.3: Added internal checks into HttpClientAndroidLog (Thanks Federico)
Added a copy of Base64.java to be compatible against Android 1.5
Added a bugfix from https://android-review.googlesource.com/#/c/15755/1//COMMIT_MSG'>Android Source tree (Thanks Louis)

2nd January 2012
1.0.2: Updated to HttpCore 4.1.4 and added HttpClient-Cache

4th October 2011
1.0.1: Bugfix for Basic Authentication
Decided to use version numbering so users do not get confused in the future.

Changes to stock HttpClient

  • Renamed all packages org.apache.http to ch.boye.httpclientandroidlib
  • Deleted all classes dependent on org.ietf.* (SPNEGO authentication)
  • Replaced org.apache.commons.codec.binary.Base64 with a copy of Android's Base64
  • Created a new class HttpClientAndroidLog to replace org.apache.commons.logging

Logging debug/error/warn information

HttpClientAndroidLog is just a simple class which has the same interface as the commons.logging.Log class. Logging can be enabled for example with

  DefaultHttpClient httpClient = new DefaultHttpClient();

httpClient.log.enableDebug(true);

Now all debug information will be output to Android LogCat. This is more or less a very simple hack which will perhaps be replaced in the future.

How to use this library

There are 2 options:

  • Use pre-compiled .jar file as external JAR library in your Android project
  • Use Android library project with all source files in Eclipse
    You can find both under Downloads. Current version includes HttpClient 4.2.1 and HttpCore 4.2.1


    You can also create your own .jar and library project by using my bash-script and any
    stock HttpClient 4.x. The script you can get by checking out the git repository.


    In your code import ch.boye.httpclientandroidlib. instead of org.apache.http.

  • Project Information

    The project was created on Aug 16, 2011.

    Labels:
    Android HTTP Networking HttpClient