当我尝试添加两个库时,尝试同步gradle时出现以下错误:
Failed to resolve: play-services-clearcut
Open File
Failed to resolve: play-services-phenotype
Open File
这是我的项目级build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
/*classpath 'com.android.tools.build:gradle:1.0.0-rc2'*/
classpath 'com.google.gms:google-services:4.0.1'
classpath 'io.fabric.tools:gradle:1.25.4'
classpath 'com.google.firebase:firebase-plugins:1.1.5'
}
}
allprojects {
repositories {
jcenter()
google()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' }
}
}
这是应用程序级别的build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'
...
dependencies {
//Firebase dependencies
implementation "com.google.firebase:firebase-messaging:17.0.0"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-config:16.0.0"
implementation 'com.google.firebase:firebase-perf:16.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
}
apply plugin: 'com.google.gms.google-services'
任何帮助将不胜感激。
答案 0 :(得分:4)
我最近遇到了这个问题,经过大量试用后出现了一个错误,认为这只是jcenter()和google()的顺序。我知道它很愚蠢,但是答案会帮助遇到同样问题的人。也要感谢@Bob Snyder在评论中指出的内容。
您的代码应如下所示:
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' }
}