Alex Moiseenkov Alex Moiseenkov - 13 days ago 7
Android Question

Can't update the project to Nougat (api 25)

I have an Android Studio project. The target- and compileSdkVersion for it - 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

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

enter image description here

And adnroid 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.

Answer

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'
}