【问题标题】:org.apache.http imports stopped working after updating to Android M更新到 Android M 后,org.apache.http 导入停止工作
【发布时间】:2015-08-23 15:30:13
【问题描述】:

我最近更新了我的应用以使用最新的 Android 6.0 SDK,但是当我发现这些导入停止工作时。

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

我尝试添加 HttpCore 和 HttpClient gradle,但只有前四个导入得到解决。

'org.apache.httpcomponents:httpcore:4.4.1'

我该如何解决这个问题?

【问题讨论】:

    标签: android import apache-commons android-6.0-marshmallow


    【解决方案1】:

    更改为 HttpURLConnection 或将其添加到您的 build.gradle 文件中:

    android {
        useLibrary 'org.apache.http.legacy'
    }
    

    这里解释:Apache HTTP Client Removal

    【讨论】:

    • 谢谢!我还需要将 /build.gradle 文件中的 gradle 版本更新为 1.3.1。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 1970-01-01
    • 2016-11-03
    • 1970-01-01
    • 1970-01-01
    • 2013-08-29
    • 1970-01-01
    相关资源
    最近更新 更多