Firebase在Android上与Kotlin无法解析的超类型

我在使用Firebase核心和消息传送v11.4.2的项目中遇到问题。

gradle同步完美工作,但编译时出现这个错误:

e:以下类的超类型无法解析。 请确保您在类路径中具有所需的依赖关系:

类com.google.android.gms.internal.zzctr,未解析的超类型:com.google.android.gms.internal.zzee

失败:生成失败,出现异常。

  • 出了什么问题:执行任务':app:compileDebugKotlin'失败。 编译错误。 查看日志了解更多详情

我已经用Kotlin版本1.1.51和1.2.0-beta-88试过; Gradle插件v2.3.3和3.0.0

欢迎任何帮助,非常感谢!

这是我配置项目的方式:

应用程序build.gradle

// tried adding and removing the -kapt and -android-extensions. Didn't help. apply plugin: 'com.android.application' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'io.fabric' debug { /// added this to be sure the class was not being left out minifyEnabled false shrinkResources false useProguard false } ... dependencies { // Firebase Core implementation "com.google.firebase:firebase-core:${rootProject.ext.firebaseVersion}" // Firebase Cloud Messaging implementation "com.google.firebase:firebase-messaging:${rootProject.ext.firebaseVersion}" } ... // Keep this as the last line or the build will fail apply plugin: 'com.google.gms.google-services' 

*项目build.gradle *

 buildscript { // App ext.compileSdkVersion = 26 ext.minSdkVersion = 18 ext.buildToolsVersion = '26.0.2' ext.targetSdkVersion = 26 // Kotlin beta, stable version doesn't compile either ext.kotlin_version = '1.2.0-beta-88' // Android ext.androidSupportVersion = '26.1.0' //TODO: implement LifecycleOwner interface from Architecture Components. ext.lifecycleVersion = '1.0.0-beta2' // Architecture, RxJava, Injection ext.daggerVersion = '2.11' ext.butterKnifeVersion = '8.8.1' ext.rxJavaVersion = '2.1.0' ext.rxAndroidVersion = '2.0.1' // Google/Firebase Cloud Message ext.firebaseVersion = '11.4.2' // Libraries shared between modules (TODO) } repositories { maven { url 'https://maven.google.com' } // Google Maven Repository maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2'} // Kotlin beta } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:3.1.1' // google-services plugin //// tried this too: classpath 'com.google.firebase:firebase-plugins:1.1.1' } allprojects { repositories { jcenter() mavenLocal() maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2'} maven { url "https://jitpack.io" } maven { url 'https://maven.google.com' } mavenCentral() flatDir { dirs 'libs' } } 

原来问题是Google电子钱包库的不兼容版本,由另一个项目依赖项实现,并与com.google.gms.google-services插件导入的版本冲突。

出于某种原因,gradle没有说明这个问题,我不得不通过代码,直到找到了Wallet试图访问一个成功导入类的地方,但同时找不到它。

只需更新其他模块中的版本,一切都是固定的:)