android 23 httpclient 替代,android api23 抛弃了httpClient,许多基于httpClient第三方库怎么办?...

android api23 抛弃了httpClient,许多基于httpClient第三方库怎么办?

在Android Studio build.gradle中添加如下,或者添加httpcore-4.4-beta1.jar

// Apache Http

android {

useLibrary 'org.apache.http.legacy'

}

// Header

dependencies {

compile "org.apache.httpcomponents:httpcore:4.3.2"

}

参考配置:

apply plugin: 'com.android.application'

//Android annotations

apply plugin: 'android-apt'

def AAVersion = '3.3.1'

android {

compileSdkVersion 23

buildToolsVersion "23.0.2"

/*api23版本 抛弃了httpClient,需要在此引用library声明,并在dependencies中引入

*compile "org.apache.httpcomponents:httpcore:4.3.2"

* 或者引入httpcore-4.4-beta1.jar

* 两者选其一

* */

useLibrary 'org.apache.http.legacy'

/*避免jar包文件混淆,打包引入不包括以下路径*/

packagingOptions {

exclude 'META-INF/DEPENDENCIES.txt'

exclude 'META-INF/LICENSE.txt'

exclude 'META-INF/NOTICE.txt'

exclude 'META-INF/NOTICE'

exclude 'META-INF/LICENSE'

exclude 'META-INF/DEPENDENCIES'

exclude 'META-INF/notice.txt'

exclude 'META-INF/license.txt'

exclude 'META-INF/dependencies.txt'

exclude 'META-INF/LGPL2.1'

}

defaultConfig {

applicationId "com.lvche.lvchedingdang"

minSdkVersion 14

targetSdkVersion 23

versionCode 1

versionName "1.0"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

/**引入so文件*/

task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") {

destinationDir file("$projectDir/libs")

baseName "Native_Libs2"

extension "jar"

from fileTree(dir: "libs", include: "**/*.so")

into "lib"

}

tasks.withType(JavaCompile) {

compileTask -> compileTask.dependsOn(nativeLibsToJar)

}

sourceSets {

main {

jniLibs.srcDirs = ['libs']

}

}

//最大堆处理

dexOptions {

incremental = true;

preDexLibraries = false

javaMaxHeapSize "4g" // 2g should be also OK

}

}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:23.1.1'

compile 'com.android.support:support-v4:22.0.0'

/*破碎玻璃动画引入*/

//compile 'com.android.support:design:22.2.0'

compile 'com.android.support:design:23.0.1'

compile project(':brokenview')

//Android annotations编译jar包路径

apt "org.androidannotations:androidannotations:$AAVersion"

compile "org.androidannotations:androidannotations-api:$AAVersion"

compile project(':lvcheapplib')

//compile "org.apache.httpcomponents:httpcore:4.3.2"

}

//Android annotations

apt {

arguments {

//老版本的写法2.2.1以前

//androidManifestFile variant.processResources.manifestFile

//2.2.1以后

androidManifestFile variant.outputs[0].processResources.manifestFile

resourcePackageName 'com.lvche.lvchedingdang'//项目包名

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值