下载资源做sync操作的时候,有时会遇到这种问题:
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.3.
Required by:
project :
> Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.3.
> Could not get resource 'https://jcenter.bintray.com/com/github/dcendents/android-maven-gradle-plugin/1.3/android-maven-gradle-plugin-1.3.pom'.
> Could not GET 'https://jcenter.bintray.com/com/github/dcendents/android-maven-gradle-plugin/1.3/android-maven-gradle-plugin-1.3.pom'.
> Connect to 127.0.0.1:1080 [/127.0.0.1] failed: Connection refused: connect
相信大家看见这个问题,本能反应就是有本地代理导致 AS 获取资源的时候远端服务器访问不到。不出意外,都会想到需要删除项目根目录 gradle.properties 内的代理配置,来解决这个问题:
systemProp.https.proxyPort=1080
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
但是,如果这样还没有解决的话
那就需要我们去 gradle 默认全局配置里去删除掉代理配置了,对应位置
Windows 在:C:\Users\Administrator.gradle下的gradle.properties中
Mac 在:/Users/.{你的用户目录}/.gradle下的gradle.properties中