[英]Project requires latest version of Kotlin
While trying to build a flutter apk, I got the following error message:在尝试构建颤振 apk 时,我收到以下错误消息:
Your project requires a newer version of the Kotlin Gradle plugin. │ │ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update │ │ /home/beingnile/Desktop/kivicare_flutter/android/build.gradle: │ │ ext.kotlin_version = '<latest-version>
I went ahead and checked the Kotlin version required and updated the build.gradle file at the root of my project.我继续检查所需的 Kotlin 版本并更新了项目根目录下的 build.gradle 文件。 I have the following code in my
build.gradle
file after updating the file:更新文件后,我的
build.gradle
文件中有以下代码:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.iqonic.kivicare"
minSdkVersion 21
targetSdkVersion 31
versionCode 9
versionName "3.5.0"
multiDexEnabled true
}
googleServices { disableVersionCheck = true }
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
ext.kotlin_version = '1.6.21'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:26.6.0')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.multidex:multidex:2.0.1'
}
After the update, I ran flutter clean
and tried to build the project again but I kept on getting the same error message.更新后,我运行
flutter clean
并尝试再次构建项目,但我不断收到相同的错误消息。 What could be the issue?可能是什么问题?
You need to change the kotlin version in your android root project, projectName/android/build.gradle
, instead of projectName/android/app/build.gradle
您需要更改 android 根项目
projectName/android/build.gradle
中的 kotlin 版本,而不是projectName/android/app/build.gradle
Change the version at ext.kotlin_version line:在 ext.kotlin_version 行更改版本:
buildscript {
ext.kotlin_version = '1.6.10' // Change here
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.