您的位置:首页 > 理论基础 > 计算机网络

Android 5.0无法使用HttpClient

2016-01-21 15:51 507 查看
在API 23中,Google已经移除了移除了Apache HttpClient相关的类 。谷歌推荐使用HttpUrlConnection,如果要继续使用需要Apache HttpClient,需要在

Eclipse下libs里添加org.apache.http.legacy.jar,

Android studio里在相应的module下的build.gradle中加入即可。
android {
useLibrary 'org.apache.http.legacy'
}

示例:
build.gradle(Moudle:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'

defaultConfig {
applicationId "com.phicomm.httptest"
minSdkVersion 21
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.1.1'
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: