Unknown host 'd29vzk4ow07wi7.cloudfront.net'. You may need to adjust the proxy settings in Gradle

更新日期: 2022-06-26 阅读次数: 14044 字数: 158 分类: Android

新安装的 Android Studio 3.2.1, 编译时报错

Unknown host 'd29vzk4ow07wi7.cloudfront.net'. You may need to adjust the proxy settings in Gradle.

估计是 cloudfront.net 被“勿忘初心”了。

解决方法:

修改项目根目录下的 build.gradle

在 google() 下添加阿里云的镜像 maven{ url'https://maven.aliyun.com/nexus/content/groups/public/'}

修改后的 build.gradle 如下

buildscript {
    
    repositories {
        google()
        maven{ url'https://maven.aliyun.com/nexus/content/groups/public/'}
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        maven{ url'https://maven.aliyun.com/nexus/content/groups/public/'}
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

VIM 快速插入

为了方便记忆,我在 VIM 中加入 snippets

> cat groovy.snippets
snippet china_source "groovy" i
maven{ url'https://maven.aliyun.com/nexus/content/groups/public/'}
endsnippet

爱评论不评论