gpt4 book ai didi

java - Android studio 无法解析符号 'HttpClient'

转载 作者:太空宇宙 更新时间:2023-11-03 11:42:39 25 4
gpt4 key购买 nike

<分区>

我有一个 Android 项目,我需要使用 http 调用。

我使用这个简单的代码:

public void onGetClick(View v) {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("http://www.google.com");
HttpResponse response = client.execute(request);

BufferedReader rd = new BufferedReader(new InputStreamReader
(response.getEntity().getContent()));

String line = "";
while ((line = rd.readLine()) != null) {
Log.d("WM.ALS", line);
}

}

但我找不到 HttpClient 库。

我将从 Apache (http://hc.apache.org/downloads.cgi) 下载的 .jar 文件添加到目录/lib 中,并添加到“build.gradle(Module: app)”文件,我添加了:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'

compile 'com.android.support:design:23.0.1'
compile 'org.apache.httpcomponents:httpcore-4.4.3'
compile 'org.apache.httpcomponents:httpclient-4.5.1'

但是还是不行..

我该怎么做?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com