如何添加的Apache HTTP API(传统)​​的编译时依赖于build.grade为Android M + [英] How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M?

查看:134
本文介绍了如何添加的Apache HTTP API(传统)​​的编译时依赖于build.grade为Android M +的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如<一个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类代替。

use the HttpURLConnection class instead.

要继续使用Apache HTTP API,则必须首先声明以下编译时依赖于你的build.gradle文件:

To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

安卓{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()

Gradle DSL method not found: '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

最新的Andr​​oid摇篮插件更新日志:<一href="http://tools.android.com/tech-docs/new-build-system">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 +的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆