HttpClient的将不会在Android的工作室导入 [英] HttpClient won't import in Android Studio
问题描述
我爬出来的我的皮肤。我拥有世界上最简单的类:
I'm crawling out of my skin. I have the world's simplest class:
package com.mysite.myapp;
import org.apache.http.client.HttpClient;
public class Whatever {
public void headBangingAgainstTheWallExample () {
HttpClient client = new DefaultHttpClient();
}
}
和由此我得到以下错误:
and from this I get the following error:
无法解析符号的HttpClient
是不是HttpClient的包括在Android SDK的工作室?即使不是这样,我把它添加到我的摇篮打造这样的:
Isn't HttpClient included in the Android Studio SDK? Even if it is not, I added it to my Gradle build like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'org.apache.httpcomponents:httpclient:4.5'
}
无论有没有最后编译行,错误是一样的。我在想什么?谢谢!
With or without the last compile line, the error is the same. What am I missing? Thanks!
推荐答案
的HttpClient
不支持任何更SDK 23.你必须使用 URLConnection的
或降级到SDK 22(编译com.android.support:appcompat-v7:22.2.0
)
HttpClient
is not supported any more in sdk 23. You have to use URLConnection
or downgrade to sdk 22 (compile 'com.android.support:appcompat-v7:22.2.0'
)
如果你需要的SDK 23,添加到您的摇篮:
If you need sdk 23, add this to your gradle:
android {
useLibrary 'org.apache.http.legacy'
}
您也可以尝试下载并包括 HttpClient的罐子直接到你的项目,或者使用的OkHttp 的,而不是
You also may try to download and include HttpClient jar directly into your project or use OkHttp instead
这篇关于HttpClient的将不会在Android的工作室导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!