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

文章目录

    新安装的 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
    }
    

    settings.gradle

    对于 Android Studio Dolphin 2021.3.1 之后的版本,国内源已经不在 build.gradle 文件中配置了,参考:

    新版本 Android Studio settings.gradle 中切换国内源

    VIM 快速插入

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

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

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式