我为此搜索了很多解决方案,但没有一个适合我的确切情况。我在 Gradle Sync 上收到此错误:
错误:任务“:app:processDebugGoogleServices”执行失败。
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.
这是在我的 build.gradle (app) 依赖项中。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
这是在我的项目级别 build.gradle 中
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
同样重要的是: 它在这条线下显示一条红线:
implementation 'com.google.firebase:firebase-auth:11.8.0'
如果我将鼠标悬停在上面,我会收到消息:
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.8.0, 11.4.2. Examples include com.google.android.gms:play-services-auth:11.8.0 and com.google.firebase:firebase-analytics:11.4.2
我什至没有分析依赖!
我该怎么办?
已经尝试过的解决方案:
如果我尝试更改我的 com.google.android.gms
版本,它会提示我不要将我的整个播放服务 bundle 在依赖项中。而且它也不会改变我遇到的 firebase 错误。
将 firebase 更改为 11.4.2 会引发 lint 错误。
将 google play services 版本更改为 3.1.1 或更低版本将不起作用。
最佳答案
如果我没记错的话,Google 服务依赖于 firebase。我认为两者是矛盾的
检查这个firebase.google.com/docs/android/setup并调整google服务和firebase依赖版本
此外,请确保您在 build.gradle (app)
文件的底部有这个:
应用插件:'com.google.gms.google-services'
关于Google 服务的 Android 版本冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48094051/