在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' }
本文详细介绍了在Android API 23版本中,Google移除ApacheHttpClient相关类后,如何通过在Eclipse或Android Studio中添加`org.apache.http.legacy.jar`文件来继续使用Apache HttpClient。提供了具体示例,包括在build.gradle文件中加入`useLibrary 'org.apache.http.legacy'`的步骤。
1285

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



