cgifox
cgifox

Reputation: 659

Android Studio 3.0 canary - Failed to resolve: org.apache.httpcomponents:httpclient:4.0.1

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.

Upvotes: 11

Views: 2928

Answers (2)

shaishgandhi
shaishgandhi

Reputation: 5688

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"
}

Upvotes: 8

zeke
zeke

Reputation: 171

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'
}

Upvotes: 5

Related Questions