在将classpath 'com.google.gms:google-services:3.3.1'
添加到build.gradle时,我收到此错误。有什么解决方案吗?
Error:Could not find com.google.gms:google-services:3.3.1.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/3.3.1/google-services-3.3.1.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/3.3.1/google-services-3.3.1.jar
https://repo1.maven.org/maven2/com/google/gms/google-services/3.3.1/google-services-3.3.1.pom
https://repo1.maven.org/maven2/com/google/gms/google-services/3.3.1/google-services-3.3.1.jar
https://dl.google.com/dl/android/maven2/com/google/gms/google-services/3.3.1/google-services-3.3.1.pom
https://dl.google.com/dl/android/maven2/com/google/gms/google-services/3.3.1/google-services-3.3.1.jar
Required by:
project :
build.gradle
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.3.1' // google-services plugin
}
}
def isReleaseBuild() {
return version.contains("SNAPSHOT") == false
}
allprojects {
version = VERSION_NAME
group = GROUP
repositories {
mavenCentral()
google()
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
apply plugin: 'android-reporting'
几件事。
项目级别生成。格拉德尔
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.31"
classpath 'com.google.gms:google-services:3.2.1'
}
我建议将您的版本降低到 3.2.1,因为 3.3.1 中存在已知问题,会影响围绕模块、风格等进行编译。
其次,请证明您在模块build.gradle中也正确应用了该插件。
示例如下:
模块级构建。格拉德尔
dependencies {
implementation 'com.google.firebase:firebase-crash:15.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
kapt "com.android.databinding:compiler:3.1.2"
//to compile @synchronized things and java references
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.31"
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.github.barteksc:android-pdf-viewer:2.7.0'
implementation 'com.wajahatkarim3.EasyFlipView:EasyFlipView:2.0.5'
// [START firebase]
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-appindexing:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
// [END firebase]
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
apply plugin: 'com.google.gms.google-services'
}
当然,您只关心谷歌GMS部分,因此请确保您拥有该插件和依赖项。