开发者

Apache HttpClient 4.1 on Android

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 开发者_JS百科4.1 with my app.


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


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).


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜