简体   繁体   English

项目需要最新版本的 Kotlin

[英]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.

相关问题 Compose Compiler 需要 Kotlin 版本 - Compose Compiler requires Kotlin version 我收到此消息:您的项目需要更新版本的 Kotlin Gradle 插件 - i am getting this message: your project requires a newer version of the Kotlin Gradle plugin 错误:您的项目升级后需要更新版本的 Kotlin Gradle 插件 - Error: Your project requires a newer version of the Kotlin Gradle plugin after upgrade it Google Play AR 需要最新版本错误 - Google Play AR requires latest version error 如何更新最新的 gradle 版本的 kotlin 库 - How to update latest gradle version of kotlin library 此版本的 Compose Compiler 需要 Kotlin 版本 1.7.20,但您似乎使用的是 Kotlin 版本 1.8.0,不知道它是否兼容 - This version Compose Compiler requires Kotlin version 1.7.20 but you appear to be using Kotlin version 1.8.0 which is not known to be compatible 该应用程序需要最新版本的ARcore吗? 这是什么意思? - the application requires the latest version of ARcore ? what does this means? 用于 AR 的 Google Play 服务需要最新版本错误 - Google Play Services for AR requires latest version error 错误:此应用程序需要用于 AR 的最新版本的 Google Play 服务 - Error: this application requires the latest version of Google Play services for AR 无法使用最新的gradle版本制作android项目 - cannot make android project with latest gradle version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM