问题描述
正如<一个href="http://developer.android.com/$p$pview/behavior-changes.html#behavior-apache-http-client">here, Android的M将不支持的Apache HTTP API。该文档状态:
As mentioned here, Android M will not support the Apache HTTP API. The docs state to:
使用的HttpURLConnection类代替。
或
要继续使用Apache HTTP API,则必须首先声明以下编译时依赖于你的build.gradle文件:
安卓{useLibraryorg.apache.http.legacy }
android { useLibrary 'org.apache.http.legacy' }
我已经转换多的HttpClient我的项目的使用情况,以HttpURLConnection类,但是,我依然的需要的使用HttpClient的少数地区。因此,我想申报org.apache.http.legacy'作为编译时的依赖,但我得到一个错误的build.gradle:
I have converted much of my project's usage of HttpClient to HttpURLConnection, however, I still need to use the HttpClient in a few areas. Hence, I am trying to declare 'org.apache.http.legacy' as a compile-time dependency but am getting an error in build.gradle:
摇篮DSL方法未找到:'useLibrary()
我的问题是:我怎么申报org.apache.http.legacy作为一个编译时依赖在我的项目
My question is: how do I declare 'org.apache.http.legacy' as a compile-time dependency in my project?
任何帮助是非常AP preciated。谢谢
Any help is much appreciated. Thanks
推荐答案
有关API 23:
顶级build.gradle - /build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
...
模块具体build.gradle - /app/build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
...
}
官方文档(为preVIEW虽然):<一href="https://developer.android.com/$p$pview/behavior-changes.html#behavior-apache-http-client">https://developer.android.com/$p$pview/behavior-changes.html#behavior-apache-http-client
最新的Android摇篮插件更新日志:http://tools.android.com/tech-docs/new-build-system
Latest android gradle plugin changelog: http://tools.android.com/tech-docs/new-build-system
这篇关于如何添加的Apache HTTP API(传统)的编译时依赖于build.grade为Android M +的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!