0

I have multiple modules in my project and have added the following dependency in my project level build.gradle file for using HTTP Client Library throughout the project:

 compile "cz.msebera.android:httpclient:4.4.1.2"

I created a new module and I want to use the above mentioned library in it. So here is what I did in build.gradle for that module:

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    useLibrary 'cz.msebera.android.httpclient'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

I have been following this post. Upon trying to sync the project I get the following error:

Error: Unable to find optional library: cz.msebera.android.httpclient

I can't figure out what went wrong here. Please help me to sort it out.

Community
  • 1
  • 1
sayres kabir
  • 362
  • 4
  • 22
  • duplicate of https://stackoverflow.com/questions/32676049/the-import-org-apache-http-client-cannot-be-resolved-error-when-i-update-sdk-to/35211175#35211175 – Shahzain ali Aug 01 '17 at 05:29
  • Possible duplicate of [The import org.apache.http.client cannot be resolved error when I update sdk to M](https://stackoverflow.com/questions/32676049/the-import-org-apache-http-client-cannot-be-resolved-error-when-i-update-sdk-to) – Shahzain ali Aug 01 '17 at 05:30

4 Answers4

1

Use this dependency in your build.gradle(Module: app):

dependencies {
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}
vss
  • 1,093
  • 1
  • 20
  • 33
  • I added to module gradle and it is work.according this site :https://hc.apache.org/httpcomponents-client-4.5.x/android-port.html version: '4.3.5.1' is for Android API 22 and older but version: '4.4.1.1' is for Android API 23 and newer . thnx. – sayres kabir Aug 01 '17 at 05:21
1

use this compile group: 'cz.msebera.android', name: 'httpclient', version: '4.4.1.1' or you can use library directly from HERE and paste it in your lib folder and choose add as library by right click on that library after paste.

jigar savaliya
  • 474
  • 1
  • 8
  • 21
0

Use

compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
Bhavesh Patadiya
  • 25,740
  • 15
  • 81
  • 107
0

Update answer for Android IDE dolphin 2021 on 12/2022 -Using cz.msebera.android , remove all org.apache.httpcomponents . Apache library create conflict with android sdk >=30. Adding this line to build.gradle file: implementation 'cz.msebera.android:httpclient:4.5.8'

-Modify all import from org.apche.http to cz.msebera.

-You can reference to my project at: https://github.com/tamobi1991/RssFeeda