簡體   English   中英

嘗試將項目連接到 firebase 時 kotlin 的不兼容版本

[英]incompatibile version of kotlin when trying to connect project to firebase

失敗是:模塊是使用不兼容版本 Kotlin 編譯的。其元數據的二進制版本為 1.7.1,預期版本為 1.5.1。

頂層 gradle

buildscript {
    ext {
        compose_version = '1.0.1'
    }

    repositories {
        google()
        mavenCentral()
    }
    dependencies{
        classpath "com.android.tools.build:gradle:7.0.4"
        classpath 'com.google.gms:google-services:4.3.14'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.1"
    }
}
plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
    id 'org.jetbrains.kotlin.android' version '1.5.21' apply false
}

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

gradle模塊

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.loginform"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:31.0.3')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation "androidx.compose.material:material-icons-extended:$compose_version"
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
}

誰能幫我? 請記住,這是一個組合應用程序,我似乎遵循每個教程如何將我的應用程序加入 firebase,但 gradle 不起作用。

如果我將 org.jetbrains.kotlin.android 版本 '1.5.21' 更改為 '1.5.1' 它會引發另一個失敗: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.jetbrains.881903282. 1.5.1', apply: false] 未在以下任何來源中找到

在項目 gradle 中:添加:

buildscript {
    ext {
        kotlin_version = "1.7.20"
        ...
        ...

並改變:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.1"
to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:kotlin_version"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM