Android 上的 Apache HttpClient 4.1
有人尝试过在 Android 上使用较新版本的 Apache HttpClient 吗? Android 使用的 HttpClient 中有一个烦人的错误,我想知道尝试使用我的应用程序重新分发 HttpClient 4.1 时是否会遇到问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我创建了一个脚本来将 HttpClient 版本转换为 Android 库项目。
这些包被重命名,这样就不会混淆使用哪些类。
ThreadSafeClientConnManager 和 Scheme 也可以正常工作。
看一下:httpclientandroidlib
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).
以防万一有人感兴趣 - 我用 Apache HttpClient 4.01 重建了我的应用程序,一切似乎都工作正常。该应用程序仅增长了 100kB。
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.
您可以找到 apache HttpClient 的 官方 android 端口在 maven 存储库 中(或查找“httpclient-android”)。
遗憾的是,Android 内置了 apache HttpClient 的一个分支,并且它停留在 4.0 版本中。
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.
我运行 4.1 运行得很好,直到我开始使用 ThreadSafeClientConnManager 和 Scheme,这产生了一些令人讨厌的运行时错误。
我怀疑使用了 Android API 中的旧方案,它具有不同的构造函数。
I was running 4.1 just fine until I started using ThreadSafeClientConnManager and Scheme which produced some nasty runtime errors.
I suspect the older Scheme in Android API is used which has a different constructor.