我在使用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
欢迎任何帮助,非常感谢!
这就是我配置项目的方式:
app 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'
* project 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'
}
}
答案 0 :(得分:1)
原来问题是Google电子钱包库的版本不兼容,由项目的其他相关人员实施,并与com.google.gms.google-services插件导入的版本冲突。
由于某些原因,gradle没有说明这个问题,我不得不仔细检查代码,直到找到Wallet试图访问成功导入但同时无法找到的类的地方。
只需更新其他模块中的版本,一切都已修复:)