0

I have an Android Studio project. The target- and compileSdkVersion for it - is 21. I want to change it to 25.

When I do this, some of the classes of the Android standard library become unavailable. For example org.apache.http.client.HttpClient.

here are some screenshots

Android classes before the rise of SDK version. You can see how many classes in org.apache.http.*

enter image description here

And Android classes after the rise of SDK version:

enter image description here

I also looked into the android reference, and saw that there is as little classes for 25 api, and (I was confused) for 21 api also. And I noticed that they are the same as I have after upgrade

enter image description here

Why in the case of 21 api, I have more classes? And how to fix it? Waiting for help. Thanks.

Daniele D.
  • 2,624
  • 3
  • 36
  • 42
Alex Moiseenkov
  • 49
  • 1
  • 10
  • 1
    "Why in the case of 21 api, I have more classes?" -- because [the built-in HttpClient was removed a year ago](https://stackoverflow.com/questions/32949626/org-apache-http-entity-fileentity-is-deprecated-in-android-6-marshmallow). "And how to fix it?" -- there is nothing to fix, other than your code. Google has been advising against using the built-in HttpClient for years. – CommonsWare Nov 27 '16 at 15:28

1 Answers1

1

Since Api 23 (Marshmallow - Android 6.0), the Apache HTTP Client has been removed.

To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

android {
    useLibrary 'org.apache.http.legacy'
}
MohanadMohie
  • 1,033
  • 1
  • 10
  • 17