【发布时间】: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。
我的问题归结为:
- 如何验证我正在使用的 Apache HttpClient 版本?
- 如何使我的应用程序使用我在 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