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?
5
  • First step is to run gradlew dependencyInsight --configuration=runtime --dependency=httpclient-android for the app project. Commented Jul 28, 2014 at 20:58
  • 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? Commented Jul 28, 2014 at 21:07
  • Try with --configuration=runtime. If this prints the same version, all should be good. Commented Jul 28, 2014 at 21:10
  • I don't specify a runtime configuration, so I only get Configuration with name 'runtime' not found. exception. Commented Jul 28, 2014 at 21:19
  • 1
    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. Commented Jul 28, 2014 at 21:26

1 Answer 1

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").

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.