Android 上的 Apache HttpClient 4.1

发布于 2024-09-16 07:01:11 字数 128 浏览 5 评论 0原文

有人尝试过在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

ゃ懵逼小萝莉 2024-09-23 07:01:11

我创建了一个脚本来将 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

懷念過去 2024-09-23 07:01:11

这看起来不是一个好主意,特别是如果新版本的客户端中没有更改包和类名称。您很可能无法预测使用哪个类(旧的或新的)。

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

尐偏执 2024-09-23 07:01:11

以防万一有人感兴趣 - 我用 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.

呆头 2024-09-23 07:01:11

您可以找到 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.

寻梦旅人 2024-09-23 07:01:11

我运行 4.1 运行得很好,直到我开始使用 ThreadSafeClientConnManager 和 Scheme,这产生了一些令人讨厌的运行时错误。

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

我怀疑使用了 Android API 中的旧方案,它具有不同的构造函数。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文