Organizational Research By

Surprising Reserch Topic

how to use the legacy apache http client on android m using -'java,android,android-gradle,android-6.0-marshmallow'

how to use the legacy apache http client on android m  using -'java,android,android-gradle,android-6.0-marshmallow'


On Android M, Google has completely removed the support of Apache HTTP client (link here) because it doesn't have good performance compared to the alternatives.

This might also be the cause for so many apps crashing on Android M.

The problem

Google allows to still use this API, just not as a built in one, by adding this line to the gradle file:

useLibrary 'org.apache.http.legacy'

So, this is what I did :

dependencies {
    classpath ''

and :

android {
    compileSdkVersion 'android-MNC'
    buildToolsVersion "23.0.0 rc3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.example.user.androidmtest"
        minSdkVersion 'MNC'
        targetSdkVersion 'MNC'
        versionCode 1
        versionName "1.0"

When I tried it, it compiled fine (no errors being shown, and I could run the POC app, as it doesn't have any special code), but when I tried using some of the classes   that I know that are part of the old API (like "HttpClient" class), I see that it doesn't allow me to do so.

I know it's not recommended to use this solution, but we must have the app ready to work there at least temporarily, till we work 100% on all of the things that should change for Android M, and we don't want surprises in the form of crashes.

Here's a screenshot:

The question

Why does it occur? Did I use it correctly ?

EDIT: reported about this issue here:

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.