android org.apache.http jar,Android无法访问org.apache.http.client.HttpClient

我正在使用

android studio创建一个向服务器发出GET请求的应用程序.我的代码是这样的:

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpGetHC4;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClientBuilder;

public class HTTPHelper

{

private String base;

public HTTPHelper (String base)

{

this.base = base;

}

public String doGet (String path)

{

try

{

CloseableHttpClient client = HttpClientBuilder.create().build();

HttpGetHC4 get = new HttpGetHC4(path);

CloseableHttpResponse response = client.execute(get);

return "";

}

catch (Exception e)

{

return null;

}

}

}

问题是Android Studio标记了这一行

client.execute(get);

有错误:

@L_502_1@

说“无法访问org.apache.http.client.HttpClient”

这是我的gradle文件:

apply plugin: 'com.android.application'

android {

compileSdkVersion 23

buildToolsVersion "23.0.0"

defaultConfig {

applicationId "principal.halloween"

minSdkVersion 16

targetSdkVersion 23

versionCode 1

versionName "1.0"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'

}

}

}

dependencies {

compile fileTree(dir: 'libs',include: ['*.jar'])

compile 'com.android.support:appcompat-v7:23.0.0'

compile 'com.pubnub:pubnub-android:3.7.5'

compile 'com.google.code.gson:gson:2.3.1'

compile group: 'org.apache.httpcomponents',name: 'httpclient-android',version: '4.3.5.1'

compile 'org.apache.httpcomponents:httpclient:4.3.6'

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值