解决Unknown host 'jcenter.bintray.com'. You may need to adjust the proxy setting

有时候从GitHub上下的项目加载老半天依赖下不下来,主要报以下错误

1
2
3
Unknown host 'jcenter.bintray.com'. You may need to adjust the proxy settings in Gradle.
Enable Gradle 'offline mode' and sync project
Learn about configuring HTTP proxies in Gradle

Click and drag to move

或者如下错误

1
2
3
ERROR: Failed to resolve: com.google.guava:guava:27.0.0-android
Show in Project Structure dialog
Affected Modules: app

Click and drag to move

解决办法只要在项目项目build.gradle文件中添加maven { url”https://jitpack.io"}即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
buildscript {
repositories {
google()
jcenter()
maven {url"https://jitpack.io"}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}

allprojects {
repositories {
google()
jcenter()
maven {url"https://jitpack.io"}
}
}

Click and drag to move