如前所述这里,Android的M将不支持的Apache HTTP API.文档声明:
请改用HttpURLConnection类.
要么
要继续使用Apache HTTP API,必须首先在build.gradle文件中声明以下编译时依赖项:
android {useLibrary'org.apache.http.legacy'}
我已经将我项目的大部分HttpClient用法转换为HttpURLConnection,但是,我仍然需要在一些领域使用HttpClient.因此,我试图将'org.apache.http.legacy'声明为编译时依赖项,但在build.gradle中出现错误:
找不到Gradle DSL方法:'useLibrary()'
我的问题是:如何在项目中将'org.apache.http.legacy'声明为编译时依赖项?
任何帮助深表感谢.谢谢
apache android httpclient build.gradle android-6.0-marshmallow
有没有办法直接在Gradle中包含Apache库以使其与Android 6.0一起使用?
我试图包括这样的库:
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
Run Code Online (Sandbox Code Playgroud)
并且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;
Run Code Online (Sandbox Code Playgroud) android apache-httpclient-4.x android-gradle-plugin android-6.0-marshmallow