0

Class apache HttpClient was declared deprecated with Android SDK 22 (v 5.1), but it is not present in Android 23 (v 6.0)!

The trouble is that all advertising SDKs, I know, apart from recent release of AdMob SDK (as a part of GMS) use HttpClient class and therefore (as far as I can see it) will crash with Android 6.0 (unless maybe in compatibility mode, which I want to avoid in order to use new 6.0 features).

SDKs, like MobFox and MoPub are open source, so they could be modified for Android SDK 23 by replacing HttpClient with URL.openConnection (this is what I actually did with MobFox), but unfortunately majority of SDKs are not like that.

The issue can be addressed to SDK developers, but on my experience it will take ages to wait for the new release.

Surprisingly enough no one posted this issue before, so I assume there should be a solution. Any ideas, or any other open-source SDKs which aren't defunct yet?

cyanide
  • 3,885
  • 3
  • 25
  • 33

2 Answers2

0

You can still use HttpClient by putting this in your application build.gradle

android {
    useLibrary 'org.apache.http.legacy'
}

More details here: https://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client

Derek Fung
  • 8,171
  • 1
  • 25
  • 28
  • Actually, I am using Eclipse. What is the Eclipse equivalent for that? Does it mean that whole apache http-client stuff will be included in my apk? – cyanide Aug 29 '15 at 12:44
  • Yes, I believe, it is including all those classes as compile time dependency. If you are still using eclipse, you should be able to find **org.apache.http.legacy.jar** in **Android/sdk/platforms/android-23/optional** However, I would suggest you to migrate to Android Studio if you have time. – Derek Fung Aug 29 '15 at 12:55
0

Just answering my own comment.

The library is found in Android-SDK-PATH/platforms/android-23/optional. Size is 297K (hopefully, the actual apk increase will be less than that after proguard optimization).

Eclipse users need to include this library to their project under libs. More information here:

How to use the legacy Apache HTTP client on Android Marshmallow?.

Thank you, Derek

Community
  • 1
  • 1
cyanide
  • 3,885
  • 3
  • 25
  • 33