赞
踩
flutter run运行项目没任何问题,但打包时终端会报错,最后打包还能成功。虽然能打包,不过这个错误警告还是要处理。
e: /Users/gamin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.23/dbaadea1f5e68f790d242a91a38355a83ec38747/kotlin-stdlib-1.9.23.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.
Flutter Fix
│ [!] Your project requires a newer version of the Kotlin Gradle plugin.
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update
│ /Users/gamin/Documents/sanqi/app_teleprompter/android/build.gradle:
│ ext.kotlin_version = '<latest-version>'
在stackoverflow上有这个问题
- buildscript {
- ext.kotlin_version = '1.9.23' // 定义一个扩展属性来指定 Kotlin 的版本
- repositories {
- google()
- mavenCentral()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:8.1.3'
- 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
- }
- plugins {
- ...
- id "com.android.application" version "8.1.3" apply false
- id "org.jetbrains.kotlin.android" version "1.9.23" apply false
- }
- ...
- # distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
- distributionUrl = https\://services.gradle.org/distributions/gradle-8.4-bin.zip
比如,文档中说Android Gradle插件版本为8.3时所需的最低Gradle版本为8.4。这时,你com.android.tools.build:gradle配置8.3.x后Gradle Wrapper版本就要改成gradle-8.4-bin.zip。
本来上面我使用版本8.3.1,但同步时报错,就改成8.1.3了。
The project is using an incompatible version (AGP 8.3.1) of the Android Gradle plugin. Latest supported version is AGP 8.1.3
注意:有时遇到同步问题,就去Android Studio中去同步,会有错误提示。在VS Code中运行时,看不到详细提示。
其中ext.kotlin_version版本信息查询:
Kotlin releases | Kotlin Documentation
com.android.tools.build版本信息查询:
https://maven.google.com/web/index.html?q=com.android.tools.build
https://mvnrepository.com/artifact/com.android.tools.build/gradle
Android Gradle插件版本配置说明:
https://developer.android.com/build/releases/gradle-plugin?hl=zh-cn#updating-gradle
distributionUrl查询:
https://services.gradle.org/distributions/
- $ flutter clean
- $ flutter pub get
- $ flutter run
- $ flutter build apk
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。