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.

2

4 Answers 4

1

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

dependencies {
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}
Sign up to request clarification or add additional context in comments.

1 Comment

I added to module gradle and it is work.according this site :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.
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.

5 Comments

i used like this: compile group: 'cz.msebera.android', name: 'httpclient', version: '4.4.1.2'
than only thing you have to do is download this library and put in your lib folder
I do but still DefaultHttpClient is deprecated.
replace HttpClient place of DefaultHttpClient
HttpClient does not have getCookieStore(). this is my another question: stackoverflow.com/questions/45420640/…
0

Use

compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'

2 Comments

instead of `cz.msebera.android:httpclient:4.4.1.21 on build.gredle of the main ?or module?
@sayreskabir you would need to write in in module dependency.
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

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.