Unknown host 'maven.google.com'

这个问题没有能直接解决…

解决方案:

app/build.gradle 原代码:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }

    dependencies {
        ...
    }
}
allprojects {

    repositories {
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

第一步:更改 url

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        maven {
            url 'https://dl.google.com/dl/android/maven2'
            name 'Google'
        }
    }

    dependencies {
        ...
    }
}
allprojects {

    repositories {
        maven {
            url 'https://dl.google.com/dl/android/maven2'
            name 'Google'
        }
    }
}

第二部,更改 hosts 文件 (Ubuntu 系统文件路径:/etc/hosts)
sudo gedit /etc/hosts
写入:203.208.40.36     dl.google.com
写入后的 hosts 文件:
在这里插入图片描述
重新编译,搞定!!!
附上参考博客:AndroidStudio编译时Unknown host ‘dl.google.com’. You may need to adjust the proxy settings

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章