這個問題沒有能直接解決…
解決方案:
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