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

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