Connection timed out connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
当build项目的时候报错:
Connection timed out connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
如图:
然后再往下看,报错信息:
A problem occurred configuring root project 'module'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.3.2.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.3.2.
> Could not get resource 'https://maven.google.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
> Could not HEAD 'https://maven.google.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
> Connect to maven.google.com:443 [maven.google.com/172.217.31.238] failed: Connection timed out: connect
如图:
意思是无法获取和编译maven.google资源,通过网上查找相关资料,说是新版的不需要设置代理和*,在build.gradle里面将maven { url “https://maven.google.com” }改为maven {url ‘https://dl.google.com/dl/android/maven2/’},如下所示(如果已经*需要把*软件关掉,并保证能上网):
buildscript {
repositories {
... ...
// maven { url "https://maven.google.com" }
maven {url 'https://dl.google.com/dl/android/maven2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}
}
allprojects {
repositories {
... ...
// maven { url "https://maven.google.com" }
maven {url 'https://dl.google.com/dl/android/maven2/'}
}
... ...
}
Android studio右上角点击Sync Now
然后编译成功!