网上查到的 版本高于api22的项目中没有httplient,因为已被google去除
较为简单的可行办法:
1.build.gradle(module:app)中添加下列两行代码
android { compileSdkVersion 24 buildToolsVersion "23.0.3" useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.newbest.smarthome.howtoaddhttpclient" minSdkVersion 18 targetSdkVersion 24 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:24.0.0' compile "org.apache.httpcomponents:httpcore:4.3.2" }
2.点击顶部菜单栏的"sync project with gradle files",整理gradle完毕即可使用httpclient
非原创,出处不详,亲测可行
本文介绍了一种在API22以上版本的Android项目中添加HttpClient的方法,因Google已从高版本中移除HttpClient,需通过特定配置实现。步骤包括在build.gradle文件中指定配置及同步Gradle。
1万+

被折叠的 条评论
为什么被折叠?



