Flutter构建Android应用遇Kotlin版本不兼容错误求助
Flutter Android构建报错:Kotlin版本不兼容
错误提示
e: /Users/Houssame/.gradle/caches/transforms-3/e5c5aa35234c44d5264fd87af440dbf9/transformed/fragment-1.7.1-api.jar!/META-INF/fragment_release.kotlin_module: 模块使用不兼容的Kotlin版本编译。其元数据的二进制版本为1.8.0,预期版本为1.6.0。
[!] 你的项目需要更新Kotlin Gradle插件版本。
获取最新版本后,更新/Users/Houssame/Desktop/demo 3/android/settings.gradle中plugins块内id为"org.jetbrains.kotlin.android"的插件版本号。或者(若项目创建于Flutter 3.19之前),更新/Users/Houssame/Desktop/demo 3/android/build.gradle中的ext.kotlin_version字段。
问题情况
已升级所有Gradle版本,但仍出现上述错误,不过应用在Android Studio模拟器中可以正常运行。
相关配置文件
Android/build.gradle
buildscript { ext.kotlin_version = '2.0.20' repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.4.2' } } 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 }
Android/app/build.gradle
plugins { id "com.android.application" id 'com.google.gms.google-services' id 'kotlin-android' id "dev.flutter.flutter-gradle-plugin" } def localProperties = new Properties() def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { flutterVersionCode = "1" } def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { flutterVersionName = "1.0" } android { namespace = "com.Inventory.App" compileSdk = 34 ndkVersion = flutter.ndkVersion compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } defaultConfig { applicationId = "com.Inventory.App" minSdk = 21 targetSdk = 34 versionCode = flutterVersionCode.toInteger() versionName = flutterVersionName } buildTypes { release { signingConfig = signingConfigs.debug } } } flutter { source = "../.." } dependencies { implementation 'androidx.core:core:1.10.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' }
Android/settings.gradle
pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath }() includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") repositories { google() mavenCentral() gradlePluginPortal() } } plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.0" apply false id "com.google.gms.google-services" version "4.3.15" apply false id "org.jetbrains.kotlin.android" version "2.0.20" apply false } include ":app"
内容的提问来源于stack exchange,提问作者AHABCHANE Houssame-Eddine
相关产品推荐
相关产品推荐

