11

I installed AS 3.0 Canary,imported an existing project, and while running gradle sync, i got this error:

Failed to resolve: org.apache.httpcomponents:httpclient:4.0.1 

I tried cleaning the project, and that failed too. This was a part of the error:

Required by: project :app > com.google.api-client:google-api-client-android:1.22.0 > com.google.http-client:google-http-client-android:1.22.0 > com.google.http-client:google-http-client:1.22.0 

I looked at other questions, and it seems like httpclient was deprecated in API 23. But every solution presented in those questions doesn't seem to work.

What's even more confusing, is that it ran perfectly fine in AS 2.4 Preview 7, with targetSdkVersion and compileSdkVersion both set to 25.

Edit: I tried running it on the stable version of AS, and it seems to work fine. But i need the newer emulators on the preview versions.

2 Answers 2

8

I had the same problem. Putting this in the module build.gradle file, at root level, fixed that error.

configurations { compile.exclude group: "org.apache.httpcomponents", module: "httpclient" } 
Sign up to request clarification or add additional context in comments.

2 Comments

where exactly? which gradle file and on which location? between android tags?
In your module build.gradle file. At root level. Not between android tags
5

Had the same problem. Ended up excluding "org.apache.httpcomponents", in my case, from "com.google.http-client:google-http-client:1.21.0".

Before:

compile 'com.google.http-client:google-http-client:1.21.0' 

After:

compile ('com.google.http-client:google-http-client:1.21.0') { exclude group: 'org.apache.httpcomponents' } 

4 Comments

Was this on 3.0? Because I also have that excluded, but it still gives me the error
Yes, I've just downloaded 3.0. If you haven't you may try to do clean/build or "Sync" gradle file. Also I've updated gradle to gradle-4.0-milestone-1 and changed gradle files to use 25.0.3 build tools (i.e. buildToolsVersion "25.0.3") if that could help.
yeah i'm getting this error only on 3.0. It works fine on stable version
How do you know which library uses that http client? i am searching, but i cannot find it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.