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

Android开发-httpclient兼容性问题

2017-08-07 23:24 561 查看
  据说android 6.0之后已经将Apache Http Client移出SDK,build时出现“Unable to find optional library: org.apache.http.legacy”,建议使用HttpURLConnetction代替,如果非要用httpclient,网上的方法是在build.gradle中加入:

android {
useLibrary 'org.apache.http.legacy'
}


  但仍然有错,还有进一步介绍要看platforms\android-23\optional目录下有没有org.apache.http.legacy.jar 和 optional.json。如果没有optional.json,则自己新建一个这样的文件,然后加入如下内容:

[
{
"name": "org.apache.http.legacy",
"jar": "org.apache.http.legacy.jar",
"manifest": false
}
]


  仍然没有。最后通过修改build参数编译通过:

android {
compileSdkVersion 25
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.myname.cartools"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐