“错误:无法解析以下类的超类型。请确保您在类路径中具有必需的依赖项”

时间:2018-08-08 09:56:59

标签: android firebase gradle kotlin dependencies

我的Android项目(Kotlin)无法编译。

成绩日志:

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

这是我的应用Gradle:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.arturpoplawski.bandmanager"
        minSdkVersion 24
        targetSdkVersion 27
        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'])

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

    //android
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'

    //firebase
    implementation 'com.google.firebase:firebase-firestore:11.8.0'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
    implementation 'com.google.firebase:firebase-auth:11.2.2'

    //picasso
    implementation 'com.squareup.picasso:picasso:2.71828'


    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-

这是项目Build Gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        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:4.0.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

1 个答案:

答案 0 :(得分:1)

要解决此问题,请更改以下代码行:

implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
implementation 'com.google.firebase:firebase-auth:11.2.2'

implementation 'com.google.firebase:firebase-firestore:17.0.4'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-auth:16.0.2'

此外,我认为这行代码是不完整的:

apply plugin: 'com.google.gms.google-

正确的整行应为:

apply plugin: 'com.google.gms.google-services'