androidStudio没有httpclient的解决办法

网上查到的 版本高于api22的项目中没有httplient,因为已被google去除

较为简单的可行办法:

1.build.gradle(module:app)中添加下列两行代码


android {
    compileSdkVersion 24
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.newbest.smarthome.howtoaddhttpclient"
        minSdkVersion 18
        targetSdkVersion 24
        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:24.0.0'
    compile "org.apache.httpcomponents:httpcore:4.3.2"
}

2.点击顶部菜单栏的"sync project with gradle files",整理gradle完毕即可使用httpclient



非原创,出处不详,亲测可行



你可能感兴趣的:(Android)