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'//项目包名
    }
}


你可能感兴趣的:(android api23 抛弃了httpClient,许多基于httpClient第三方库怎么办?)