以下类的超类型无法解析

5

我有一个使用 kotlin 编写的 android 应用程序,出现了以下错误:

错误:无法解析以下类的超类型。请确保您在类路径中具有所需的依赖项: class com.google.firebase.auth.FirebaseAuth,未解决的超类型:com.google.android.gms.internal.aad

还有这个错误:

错误:任务“:app:compileDebugKotlin”执行失败。

编译错误。请查看日志获取更多详细信息。

这是我的应用程序模块。

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "appname"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

     implementation 'com.android.support:appcompat-v7:26.1.0'
     implementation 'com.android.support:animated-vector-drawable:26.1.0'
    implementation 'com.android.support:mediarouter-v7:26.1.0'
   implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'

    implementation 'com.firebaseui:firebase-ui-database:3.0.0'



    //noinspection GradleCompatible,GradleCompatible
    implementation 'com.google.android.gms:play-services:11.0.4'
    implementation 'com.google.firebase:firebase-auth:11.0.4'
    implementation 'com.google.firebase:firebase-database:11.0.4'
    implementation 'com.google.firebase:firebase-storage:11.0.4'
    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'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

}

 repositories {
    mavenCentral()
}
apply plugin: 'com.google.gms.google-services'

我的项目Gradle文件如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.51'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我已经实现了firebase.auth,但仍然出现错误。


你尝试过改变依赖项的顺序吗? - Alex Mamo
7个回答

7

com.firebaseui:firebase-ui-auth更新到3.3.1版本,问题就解决了。因为旧版本(我这里使用的是3.1.0)与com.google.firebase:firebase-messaging v15不兼容。


谢谢 @Rishabh876,implementation 'com.google.firebase:firebase-auth:19.0.0' 解决了我的问题。 - Tariq Mahmood

3

将所有来自“com.google.android.gms:”组的依赖项和firebase-messaging版本更新为15.0.0,而不是12.0.1,可以为我解决此问题。


1
请在gradle中添加以下内容:

implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'


1
另一种可能发生的情况是,您在模块中使用了implementation而不是api来使用其中一个依赖项,这可能会与另一个依赖项发生冲突。

1
我看到你的Gradle文件中至少有两个问题:
  1. You have a duplicated entry for "kotlin-stdlib-jre7" (one implementation and one compile). Remove the last one:

    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    
  2. Not using the latest versions of firebase & google play services: update to firebase 11.6.2


0
如果您正在使用 firebase-bom,则应更新到最新版本。对于我来说,升级到最新版本后它开始正常工作。
截至目前的最新版本:

com.google.firebase:firebase-bom:24.5.0

您可以在这里检查最新版本


-2

添加这个解决了我的问题

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接