HttpClient won't import in Android Studio

后端 未结 23 2962
一生所求
一生所求 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:11

    HttpClient was deprecated in API Level 22 and removed in API Level 23. You can still use it in API Level 23 and onwards if you must, however it is best to move to supported methods to handle HTTP. So, if you're compiling with 23, add this in your build.gradle:

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

提交回复
热议问题