Apache HTTP 连接 Android 6.0 (Marshmallow)
Apache HTTP connection with Android 6.0 (Marshmallow)
有什么方法可以直接在 Gradle 中包含 Apache 库以使其与 Android 6.0 一起使用?
我试过包含这样的库:
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
并且 Android Studio 无法找到以下导入:
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.auth.DigestScheme;
根据 API 22-23 差异更改,org.apache.http.* 包已从 Android 6.0 (Marshmallow) API 级别 23 开始删除。
http://developer.android.com/sdk/api_diff/23/changes.html
通过:http://android-developers.blogspot.co.uk/2015/08/m-developer-preview-3-final-sdk.html
This page 讨论了 Apache HTTP 的删除 类,它也提出了一个解决方法:
To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:
android {
useLibrary 'org.apache.http.legacy'
}
就我而言 Android Studio 仍然抱怨找不到这些 类,但应用程序确实构建了并且 运行.
该页面确实建议您移至 HttpURLConnection。
有什么方法可以直接在 Gradle 中包含 Apache 库以使其与 Android 6.0 一起使用?
我试过包含这样的库:
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
并且 Android Studio 无法找到以下导入:
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.auth.DigestScheme;
根据 API 22-23 差异更改,org.apache.http.* 包已从 Android 6.0 (Marshmallow) API 级别 23 开始删除。
http://developer.android.com/sdk/api_diff/23/changes.html
通过:http://android-developers.blogspot.co.uk/2015/08/m-developer-preview-3-final-sdk.html
This page 讨论了 Apache HTTP 的删除 类,它也提出了一个解决方法:
To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:
android { useLibrary 'org.apache.http.legacy' }
就我而言 Android Studio 仍然抱怨找不到这些 类,但应用程序确实构建了并且 运行.
该页面确实建议您移至 HttpURLConnection。