HttpPost is not resolved in my class in my application

1

I can not import org.apache.http.conn class into my application in Eclipse.

This is my class:

package br.com.cadastro.cadastrocompleto.suporte;

import java.io.IOException;

public class WebClient {

    private String url;

    public WebClient(String url){
        this.url = url;
    }

    public void post(String json){
        try {
            HttpPost post = new HttpPost(url);
            post.setEntity(new StringEntity(json));
            post.setHeader("Accept", "application/json");
            post.setHeader("Content-type", "application/json");

            HttpClient httpClient = new HttpClient();
            HttpResponse response = httpClient.execute(post);

            String jsonDeResposta = EntityUtils.toString(response.getEntity());

        }catch(IOException e){
            e.printStackTrace();    
        }
    }
}

What can I do about it?

EDIT

It looks like this in Eclipse:

    
asked by anonymous 11.02.2016 / 16:00

1 answer

1

You can add libraries in several ways. It's available in the public repository, so if you use , you can add it's like this:

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient-android</artifactId>
    <version>4.3.5.1</version>
</dependency>

If you use , you can simply declare it as follows :

compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'

If you do not use any of these (or other) dependency manager, you can download directly from site (code here ), unpack and add the libraries in the lib directory that are necessary for your case. / p>

Last alternative is to download directly from a dependency crawler, such as MVN Repository

    
11.02.2016 / 16:55