Flutter Kotlin 版本 1.9

问题描述 投票:0回答:1

版本:1.0.0+1 环境:sdk:'>=3.2.3 <4.0.0' dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.6 bloc: ^8.1.2 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.9 google_fonts: ^6.1.0 equatable: ^2.0.5 mask_text_input_formatter: ^2.8.0 flutter_secure_storage: ^9.0.0 http: ^1.1.2 pin_code_fields: ^8.0.1 shimmer: ^3.0.0 google_maps_flutter: ^2.5.3 geolocator: ^10.1.0 # location: ^5.0.0 flutter_rating_stars: ^1.0.3+4 flutter_polyline_points: ^2.0.0 url_launcher: ^6.2.3 intl: ^0.19.0 googleapis: ^12.0.0 flutter_slidable: ^3.0.1 firebase_core: ^2.24.2 firebase_messaging: ^14.7.10 # overlay_support: ^2.1.0 permission_handler: ^11.2.0

错误文本-

: C:/Users/azimz/.gradle/caches/transforms-3/889ce5bd12f1117e5357d5fcdb5e1305/transformed/core-1.10.1/jars/classes.jar!/META-INF/core_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

e: C:/Users/azimz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.0/8ee15ef0c67dc83d874f412d84378d7f0eb50b63/kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.

e: C:/Users/azimz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.0/8ee15ef0c67dc83d874f412d84378d7f0eb50b63/kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.

e: C:/Users/azimz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.0/8ee15ef0c67dc83d874f412d84378d7f0eb50b63/kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.

e: C:/Users/azimz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.9.0/cd65c21cfd1eec4d44ef09f9f52b6d9f8a720636/kotlin-stdlib-common-1.9.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.  

-- 构建 Gradle

buildscript {
    ext.kotlin_version = '1.9.0'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
    
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

当我构建 apk 时出现错误

flutter kotlin build compiler-errors apk
1个回答
0
投票

您在Android Studio中安装的Kotlin版本与Flutter项目使用的Kotlin版本似乎不匹配。尝试将两者匹配。 您可以通过进入 flutter 项目的 android 文件夹内的 build.gradle 文件来检查您的 kotlin 版本

© www.soinside.com 2019 - 2024. All rights reserved.