異常以下:android
Error:FAILURE: Build failed with an exception.app
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not resolve com.google.android.gms:play-services-ads:latest.release.
Required by:
project :app
> Could not resolve com.google.android.gms:play-services-ads:12.0.1.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads/12.0.1/play-services-ads-12.0.1.pom'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads/12.0.1/play-services-ads-12.0.1.pom'.
> Read timed outmaven
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.gradle
* Get more help at https://help.gradle.orgui
BUILD FAILED in 35s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
解決方案以下:
在project級別下的build.gradle文件中添加以下代碼:google
buildscript {url
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1' //這裏不用和我同樣,和你項目裏面的版本同樣就行
classpath 'com.google.gms:google-services:4.0.1' //這行對谷歌服務庫進行依賴spa
}
}.net
allprojects {
repositories {
google()
jcenter()
mavenCentral ()
maven {url 'https://dl.bintray.com/jetbrains/anko'} //這是你須要加入的,這個是解決這個問題的關鍵地方,我就是添加這個maven後再也不報上面的錯誤了
maven {url "https://maven.google.com"} //谷歌廣告
}
}debug