HttpClient won't import in Android Studio

后端 未结 23 2419
一生所求
一生所求 2020-11-22 14:44

I have a simple class written in Android Studio:

package com.mysite.myapp;

import org.apache.http.client.HttpClient;

public class Whatever {
    public voi         


        
23条回答
  •  囚心锁ツ
    2020-11-22 15:14

    HttpClient is not supported any more in sdk 23. Android 6.0 (API Level 23) release removes support for the Apache HTTP client. You have to use

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

    and also add below code snippet in your dependency :

    //http final solution for web-service (including file uploading)

    compile('org.apache.httpcomponents:httpmime:4.3.6') {
            exclude module: 'httpclient'
    }
     compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
    

    It will also help you while you use Use MultipartEntity for File upload.

提交回复
热议问题