Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 388
Guest1997 Avatar asked May 22 '17 09:05

Guest1997


2 Answers

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'
}
like image 122
zeke Avatar answered Nov 12 '22 12:11

zeke


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"
}
like image 8
shaishgandhi Avatar answered Nov 12 '22 12:11

shaishgandhi