Has anyone tried to use a newer version of Apache HttpClient on Android? There's an annoying bug in the HttpClient used by Android and I was wondering if I would run into problems trying to redistribute HttpClient 4.1 with my app.
5 Answers
I created a script to convert a stock HttpClient release into an Android library project. The packages are renamed so that there's no confusion of which classes are used.
Also ThreadSafeClientConnManager and Scheme work just fine.
Take a look: httpclientandroidlib

- 156
- 1
- 4
-
dirkboye: how to repackage it on my own? http://stackoverflow.com/questions/21134237/how-to-repackage-httpclient-4-3-1-and-remove-dependencies-on-commons-logging Or can you update the lib to use HttpClient 4.3.1? – Stuck Jan 15 '14 at 10:13
That doesn't looks as good idea, especially if package and class names were not changed in newer version of Client. Most likely you will not be able to predict which class is used (old or new).

- 68,980
- 16
- 115
- 93
-
If you use the Maven Shade Plugin you can just move it all to a different package and be save using it. – Manfred Moser Feb 21 '11 at 04:08
Just in case anyone is interested - I rebuilt my app with Apache HttpClient 4.01 and everything seems to work fine. The app has grown only by 100kB.

- 4,075
- 6
- 49
- 50
-
Can you give us some step-by-step instruction how to build against HTTPClient 4.x instead of built-in version? – Ognyan Jul 14 '11 at 19:45
-
Mine has grown by 250kB (Apache HttpClient 4.2.1), latest version of httpclientandroidlib from July 2012 – Twilite Nov 08 '12 at 14:06
-
Ogre_BGR: did you find any solution? I am trying to repackage on my own for use of HttpClient 4.3.1: http://stackoverflow.com/questions/21134237/how-to-repackage-httpclient-4-3-1-and-remove-dependencies-on-commons-logging – Stuck Jan 15 '14 at 10:15
There's an official android port of apache HttpClient you can find in maven repository (or look for "httpclient-android").
Sadly Android comes with a fork of apache HttpClient built in and it's stuck in version 4.0.

- 5,556
- 5
- 42
- 60
I was running 4.1 just fine until I started using ThreadSafeClientConnManager and Scheme which produced some nasty runtime errors.
ERROR/dalvikvm(1077): Could not find method org.apache.http.conn.scheme.Scheme.<init>, referenced from method com.example.MyActivity.download
WARN/dalvikvm(1077): VFY: unable to resolve direct method 3290: Lorg/apache/http/conn/scheme/Scheme;.<init> (Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
WARN/dalvikvm(1077): VFY: rejecting opcode 0x70 at 0x0035
I suspect the older Scheme in Android API is used which has a different constructor.

- 4,033
- 2
- 24
- 29