HttpClient won't import in Android Studio

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

    in API 22 they become deprecated and in API 23 they removed them completely, a simple workaround if you don't need all the fancy stuff from the new additions is to simply use the .jar files from apache that were integrated before API 22, but as separated .jar files:

    1. http://hc.apache.org/downloads.cgi
    2. download httpclient 4.5.1, the zile file
    3. unzip all files
    4. drag in your project httpclient-4.5.1.jar, httpcore-4.4.3.jar and httpmime-4.5.1.jar
    5. project, right click, open module settings, app, dependencies, +, File dependency and add the 3 files
    6. now everything should compile properly
    

提交回复
热议问题