【问题标题】:How to upgrade Apache HttpClient Versions on Android如何在 Android 上升级 Apache HttpClient 版本
【发布时间】:2014-07-28 19:55:55
【问题描述】:

我已将 HttpClient 4.3.3 for android 添加到我的 build.gradle 文件中,名称为 described by Apache,但我的应用程序的大小没有改变。因此,我很确定,虽然我的 IDE 将 httpclient-android-4.3.3 显示为外部库,但我的应用实际上并未包含和使用它。

我尝试根据this post验证http客户端的版本,但是VersionInfo.loadVersionInfo()一直返回null。

我的问题归结为:

  1. 如何验证我正在使用的 Apache HttpClient 版本?
  2. 如何使我的应用程序使用我在 Gradle 中指定的版本?我应该在我的 gradle 构建中排除 Android HttpClient 吗?

【问题讨论】:

  • 第一步是为应用项目运行gradlew dependencyInsight --configuration=runtime --dependency=httpclient-android。
  • 运行该命令会显示Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0 :myApp:dependencyInsight org.apache.httpcomponents:httpclient-android:4.3.3 \--- compile 这是否意味着我正在使用较新版本的httpclient 而不是android 框架的版本?
  • 试试--configuration=runtime。如果这打印相同的版本,一切都应该是好的。
  • 我没有指定运行时配置,所以只得到Configuration with name 'runtime' not found.异常。
  • 好的,Android 版本似乎没有 runtime 配置。无论如何,根据 Android 文档:“编译配置用于编译主应用程序。其中的所有内容都添加到编译类路径中,并打包在最终的 APK 中。”。因此应该包括lib。 Android如何处理内置和外置http-client版本冲突我不知道。

标签: java android apache gradle apache-commons-httpclient


【解决方案1】:

Android 带有一个内置的 apache HttpClient 4.0 分支,当您尝试导入较新版本时,gradle 将忽略。 (它给了我一个警告:“依赖 org.apache.httpcomponents:httpclient:4.4.1 被忽略以进行调试,因为它可能与 Android 提供的内部版本冲突。”)

有一个official 解决方法。它是 httpclient 的一个分支,具有不同的包名称和其他兼容性更改。您可以在maven repository 中找到它(或查找“httpclient-android”)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2020-06-24
    • 2018-10-27
    • 2018-09-20
    • 2022-12-20
    相关资源
    最近更新 更多