簡體   English   中英

項目需要最新版本的 Kotlin

[英]Project requires latest version of Kotlin

在嘗試構建顫振 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>

我繼續檢查所需的 Kotlin 版本並更新了項目根目錄下的 build.gradle 文件。 更新文件后,我的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'
}

更新后,我運行flutter clean並嘗試再次構建項目,但我不斷收到相同的錯誤消息。 可能是什么問題?

您需要更改 android 根項目projectName/android/build.gradle中的 kotlin 版本,而不是projectName/android/app/build.gradle

在 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM