Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import org.apache.http.HttpResponse in Android Studio

I want to use these libraries in Android Studio:

import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; 

I am following a video tutorial in which the tutor is using Eclipse so I know it works.

But what additional things/libraries do I have to add to Android Studio in order to use them?

like image 300
Mohsin Anees Avatar asked Sep 01 '15 20:09

Mohsin Anees


People also ask

What is org Apache HttpComponents?

The Apache HttpComponents project is responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. This project functions under the Apache Software Foundation (http://www.apache.org), and is part of a larger community of developers and users.

What is HttpClient Android?

Most network-connected Android apps will use HTTP to send and receive data. Android includes two HTTP clients: HttpURLConnection and Apache HTTP Client. Both support HTTPS, streaming uploads and downloads, configurable timeouts, IPv6 and connection pooling.


1 Answers

HttpClient is deprecated in sdk 23.

You have to move on URLConnection or down sdk to 22

Still you need HttpClient with update gradle sdk 23

You have to add the dependencies of HttpClient in app/gradle as

dependencies {     compile fileTree(include: ['*.jar'], dir: 'libs')     compile 'com.android.support:appcompat-v7:23.0.1'      compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'     ... } 
like image 147
TejaDroid Avatar answered Sep 19 '22 22:09

TejaDroid