Apache HttpClient 4.1 on Android

佐手、 提交于 2019-11-27 04:43:40

问题


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.


回答1:


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




回答2:


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




回答3:


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:


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:


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.



来源:https://stackoverflow.com/questions/3577035/apache-httpclient-4-1-on-android

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