【问题标题】:incompatibile version of kotlin when trying to connect project to firebase尝试将项目连接到 firebase 时 kotlin 的不兼容版本
【发布时间】:2022-11-21 07:08:35
【问题描述】:

失败是: 模块是使用不兼容的 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
}

渐变模块

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: 插件 [id: 'org.jetbrains.kotlin.android', version: '1.5.1',​​ apply: false] 在以下任何来源中都找不到

【问题讨论】:

  • 尝试更新您的版本并检查兼容性map。请注意,您可以删除顶级文件中的插件块。
  • 我试过了,但没有用。还有其他想法吗?
  • 更新到最新版本:compose 1.3.x

标签: android firebase kotlin gradle android-jetpack-compose


【解决方案1】:

在项目等级中: 添加:

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"

【讨论】:

    猜你喜欢
    • 2021-09-10
    • 1970-01-01
    • 2022-08-09
    • 1970-01-01
    • 1970-01-01
    • 2021-05-07
    • 2021-04-01
    • 2021-07-23
    • 2019-09-27
    相关资源
    最近更新 更多