android studio使用httpclient问题

caixunwei 2015-11-06 10:47:33
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;


在android studio上显示无法解析,上网查了下说要导jar包,于是我就下载了http的包,如下图

我把所有的jar包都解压进去了!
可结果还是无法解析,按android studio的提示去网上下载相对应的jar包也找不到。。。求大神解决!
...全文
10031 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
pzzpztyy2009 2017-05-01
  • 打赏
  • 举报
回复
12楼,请问之后怎么解决的
陈小他 2017-03-20
  • 打赏
  • 举报
回复
我也遇到了这个问题,可是,我在里面加了这句话,还是报错啊,说找不到 我在Gradle Scripts里面的build.gradle(Module.app)里面加了这段代码就像这样 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.jlxy.chen.eroad" minSdkVersion 19 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']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.1' } android { useLibrary 'org.apache.http.legacy' } 可是用HttpClient还是出错是为啥呢
qxd100 2016-10-25
  • 打赏
  • 举报
回复
这个很有用!
张云勇 2016-07-18
  • 打赏
  • 举报
回复
引用 2 楼 jklwan 的回复:
在相应的module下的build.gradle中加入: android { useLibrary 'org.apache.http.legacy' }
正解。是添加到Module的buid.gradle中
qq_31709161 2016-04-21
  • 打赏
  • 举报
回复
6楼正解啊,我用这个方法在gradle里面添加,解决了问题,谢谢
happyguns 2016-03-08
  • 打赏
  • 举报
回复
看了好多帖子,试了好多方法,最终用6#的方法解决了。切记加那句代码的时候libs里面千万不要导HttpClient相关的jar包,我就是犯了这个错,兜了一大圈又回到了这里。
Lain_ComeOn 2015-12-16
  • 打赏
  • 举报
回复
楼主 你好 我想知道 你在什么地方 改成了httpURLConnection 能告诉我一下么?
JarQ 2015-11-08
  • 打赏
  • 举报
回复
引用 4 楼 caixunwei 的回复:
[quote=引用 1 楼 qJay_Dev 的回复:] 6.0就隐藏了此API,但官方也说了怎么用,具体可以去官方看说明
能否给个具体的链接。。[/quote] /*--------------------------------------------------------*/ //官方原文 Apache HTTP Client Removal Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file: android { useLibrary 'org.apache.http.legacy' } /*--------------------------------------------------------*/ 原文地址:http://developer.android.com/intl/zh-cn/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client
caixunwei 2015-11-08
  • 打赏
  • 举报
回复
最后换httpURLConnection解决了。。
jklwan 2015-11-07
  • 打赏
  • 举报
回复
在相应的module下的build.gradle中加入: android { useLibrary 'org.apache.http.legacy' }
JarQ 2015-11-07
  • 打赏
  • 举报
回复
6.0就隐藏了此API,但官方也说了怎么用,具体可以去官方看说明
caixunwei 2015-11-07
  • 打赏
  • 举报
回复
引用 1 楼 qJay_Dev 的回复:
6.0就隐藏了此API,但官方也说了怎么用,具体可以去官方看说明
能否给个具体的链接。。
caixunwei 2015-11-07
  • 打赏
  • 举报
回复
引用 2 楼 jklwan 的回复:
在相应的module下的build.gradle中加入: android { useLibrary 'org.apache.http.legacy' }
是build.gradle里面吗?我加了怎么还是没用。。难道我位置加错了?

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧