Gradle配置之常见问题-Could not resolve com.android.tools.build:gradle

Gradle配置之常见问题-Could not resolve com.android.tools.build:gradle
问题现象:

  • What went wrong:
    A problem occurred configuring root project ‘Server’.

Could not resolve all dependencies for configuration ‘:classpath’.
Could not resolve com.android.tools.build:gradle:2.1.2.
Required by:
:Server:unspecified
Could not resolve com.android.tools.build:gradle:2.1.2.
Could not get resource ‘https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.2/gradle-2.1.2.pom’.
Could not HEAD ‘https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.2/gradle-2.1.2.pom’. Received status code 400 from server: Bad Request
Could not resolve com.google.guava:guava:10.0.1.
Required by:
:Server:unspecified > com.google.protobuf:protobuf-gradle-plugin:0.7.6 > com.google.gradle:osdetector-gradle-plugin:1.2.1 > kr.motd.maven:os-maven-plugin:1.2.3.Final > org.apache.maven:maven-plugin-api:3.2.1 > org.eclipse.sisu:org.eclipse.sisu.plexus:0.0.0.M5
Could not resolve com.google.guava:guava:10.0.1.
Could not get resource ‘https://jcenter.bintray.com/com/google/guava/guava/10.0.1/guava-10.0.1.pom’.
Could not GET ‘https://jcenter.bintray.com/com/google/guava/guava/10.0.1/guava-10.0.1.pom’. Received status code 400 from server: Bad Request

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

分析过程:
使用浏览器直接访问’https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.2/gradle-2.1.2.pom’的话,可以正常访问。

根本原因:
这里可以说明是gradle存在的代理原因,导致无法访问网址。这样在gradle.properties文件中去掉代理即可。
注意:代理存在两个地方,都需要去掉,一个地方是代码工程中;另一个地方是系统用户文件夹C:\Users\用户名.gradle

你可能感兴趣的:(Gradle配置之常见问题-Could not resolve com.android.tools.build:gradle)