无法在Android Studio中解析符号HttpGet,HttpClient,DefaultHttpClient [英] Cannot resolve symbol HttpGet,HttpClient,DefaultHttpClient in Android Studio
本文介绍了无法在Android Studio中解析符号HttpGet,HttpClient,DefaultHttpClient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是我的应用程序中的android新手,正在与服务集成,因此当我导入所有这些jar文件时.它给出了一个错误:
Hi I am new for android in my app I am integrating with services so when I import all these jar files. It gives an error :
无法解析符号HttpGet,HttpClient,DefaultHttpClient.
Cannot resolve symbol HttpGet,HttpClient,DefaultHttpClient.
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
我的构建gradle:-
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
}
推荐答案
HttpClient在API级别22中已弃用,并在API级别23中已已删除.您必须使用URLConnection
.
HttpClient was deprecated in API Level 22 and removed in API Level 23. You have to use URLConnection
.
如果您仍然需要23,请将其添加到gradle ::
If you anyway need in 23, add this to your gradle::
android {
useLibrary 'org.apache.http.legacy'
}
注意:相反,我建议使用 OkHttp .
NOTE: Instead, I would recommend using OkHttp.
这篇关于无法在Android Studio中解析符号HttpGet,HttpClient,DefaultHttpClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文