【问题标题】:Supertypes of the following classes cannot be resolved以下类的超类型无法解析
【发布时间】:2018-05-20 10:49:30
【问题描述】:

我在kotlin 中有android app,这给了我这个错误。

错误:无法解析以下类的超类型。请确保您在类路径中具有所需的依赖项: 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 implementation,但它仍然向我显示错误。

【问题讨论】:

  • 您是否尝试过更改依赖项的顺序?

标签: android firebase gradle kotlin firebase-authentication


【解决方案1】:

如果您使用的是 firebase-bom,那么您应该更新到最新版本。对我来说,升级到最新版本后它开始工作了。

截至目前的最新版本:

com.google.firebase:firebase-bom:24.5.0

您可以查看最新版本HERE

【讨论】:

    【解决方案2】:

    在 gradle 中添加以下内容:-

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

    【讨论】:

      【解决方案3】:

      可能发生的另一件事是您使用implementation 而不是api 作为您的一个依赖项,这可能与您模块中的另一个依赖项发生冲突。

      【讨论】:

        【解决方案4】:

        添加这个解决了我的问题

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

        【讨论】:

          【解决方案5】:

          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' 解决了我的问题。
          【解决方案6】:

          将“com.google.android.gms:”组中的所有依赖项以及 firebase-messaging 版本更新到 15.0.0。而不是 12.0.1 为我解决了这个问题。

          【讨论】:

            【解决方案7】:

            我在您的 gradle 文件中看到至少 2 个问题:

            1. 您有一个重复的“kotlin-stdlib-jre7”条目(一个实现和一个编译)。删除最后一个:

              compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
              
            2. 未使用最新版本的 firebase 和 google play 服务:更新至 firebase 11.6.2

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2012-10-08
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2015-10-22
              相关资源
              最近更新 更多