2

I would like to use Apache HttpClient 4.5, so the line

compile 'org.apache.httpcomponents:httpclient:4.5'

is added in my build.gradle, and I get the following in Gradle Console

Configuration on demand is an incubating feature.
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages

I would like to know what is the problem and how could I solve it. Thanks^^

chunchiu Chan
  • 199
  • 3
  • 14

1 Answers1

1

Go to Apache, I have found for Android they use HttpClient for Android 4.3.5. My projects use these Jar files as library (not compiled in gradle). You can try download here. Hope this help!

BNK
  • 23,994
  • 8
  • 77
  • 87
  • 1
    This is no longer usable with API23 (compileSdk) because all classes `org.apache.http` will be shown as missing, and Android version of HC `4.3.5.1` doesn't include them because they relied on Android SDK to provide the legacy headers. – Marek Sebera Aug 24 '15 at 09:17
  • @Marek Sebera: thanks for your information. I have not tested any project with API23 yet. – BNK Aug 24 '15 at 10:00
  • @MarekSebera: I have just created a sample project with `compileSdkVersion 23 buildToolsVersion "23.0.0"` and add `httpcore-4.3.jar`, `httpmime-4.3.jar`. App runs without any error – BNK Aug 25 '15 at 02:30
  • what minimal sdk version? Also what level is your device? Can you share please? – Marek Sebera Aug 25 '15 at 04:02
  • @MarekSebera: `minSdkVersion 16`, I have run the app in real phone (Android 4.1.2) – BNK Aug 25 '15 at 04:07
  • Using Http calls? Eg. Head or Delete which are not in default Android code? Do you build with gradle? Are uou using Androif Studio? – Marek Sebera Aug 25 '15 at 04:10
  • I use Android Studio, project built with gradle. I have just only added 2 lines `MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);` and runs without any error – BNK Aug 25 '15 at 04:12
  • well strange, nothing show on build or lint? because this should be handled as possible classpath conflict which gradle avoids by excluding the libraries. Also can you please try to include those jars through Maven dependency instead of local JAR dependency? Thanks – Marek Sebera Aug 25 '15 at 04:52
  • I am not familiar with Maven :). Do you need my full source code or not? – BNK Aug 25 '15 at 04:58
  • Well would be nice, if you start up new project and set it up with Gradle, AS and HttpClient 4.X, and it will run for you, to put it on github, so we could test it, but I was not able to do so. Also I just noticed, you're just putting HttpCore and HttpMime, try to put there HttpClient-4.3.jar too, and see if it makes any difference. – Marek Sebera Aug 25 '15 at 05:24
  • @MarekSebera: I added my sample code to GitHub, please go [here](https://github.com/ngocchung/android-api23) – BNK Aug 25 '15 at 06:32
  • So I was right after all, see the debug info in https://github.com/ngocchung/android-api23/issues/1 – Marek Sebera Aug 25 '15 at 06:58
  • @MarekSebera: if use `compile 'org.apache.httpcomponents:httpclient:4.4.1'` in gradle file, it not working not only API23 but also API22, perhaps other ones. So, for the OP's issue, I suggest him to use JAR files instead. – BNK Aug 25 '15 at 07:25