Apache HttpClient 4.1 on Android

血红的双手。 提交于 2019-11-28 00:16:52

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.

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