How to upgrade Apache HttpClient Versions on Android
Asked Answered
A

1

6

I've added HttpClient 4.3.3 for android to my build.gradle file as described by Apache, but my app hasn't changed in size. Because of this I'm pretty sure that, while my IDE shows httpclient-android-4.3.3 as an External Library, it's not actually being included and used by my app.

I've tried to verify the version of http client according to this post, but VersionInfo.loadVersionInfo() keeps returning null.

My questions boil down to:

  1. How do I verify the version of Apache HttpClient that I'm using?
  2. How do I make it so that my app uses the version I've specified in Gradle? Am I supposed to exclude the Android HttpClient in my gradle build?
Anchusin answered 28/7, 2014 at 19:55 Comment(5)
First step is to run gradlew dependencyInsight --configuration=runtime --dependency=httpclient-android for the app project.Wayward
Running that command shows Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0 :myApp:dependencyInsight org.apache.httpcomponents:httpclient-android:4.3.3 \--- compile Does this mean I'm using the newer version of httpclient over the android framework's version?Anchusin
Try with --configuration=runtime. If this prints the same version, all should be good.Wayward
I don't specify a runtime configuration, so I only get Configuration with name 'runtime' not found. exception.Anchusin
OK, Android builds don't seem to have a runtime configuration. Anyhow, according to the Android docs: "The compile configuration is used to compile the main application. Everything in it is added to the compilation classpath and also packaged in the final APK.". Hence the lib should be included. How Android deals with the conflict between the built-in and the external http-client version I don't know.Wayward
I
3

Android comes with a fork of apache HttpClient 4.0 built in and gradle will ignore when you try to import a newer version. (It gives me a warning: "Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android.")

There's an official workaround. It's a fork of httpclient with different package names and other compatibility changes. You can find it in maven repository (or look for "httpclient-android").

Intrados answered 8/6, 2015 at 23:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.