Flutter:KotlinGradle插件版本

rpppsulh  于 2023-05-29  发布在  Kotlin
关注(0)|答案(1)|浏览(280)

我遇到了一个AndroidKotlin版本的问题。我用ext.kotlin_version = '1.7.10'。但是,它显示了这个类型错误。

FAILURE: Build failed with an exception.

* What went wrong:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
The following dependencies do not satisfy the required version:
project ':platform_device_id' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
Running Gradle task 'assembleDebug'...                              9.7s
Exception: Gradle task assembleDebug failed with exit code 1

下面是我的build.gradle文件:

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
         classpath 'com.google.gms:google-services:4.3.13'
        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
}
jdzmm42g

jdzmm42g1#

在这个错误看到[platform_device_id]插件支持Android和Kotlin版本是如此缓慢.
你可以去pub下载platform_device_id插件,在[Downloads/platform_device_id-1.0.1/android/build.gradle]中将[ext. kotlin_version ='1.3.50']更改为[ext.kotlin_version = '1.5.20']。
下载网址:https://pub.flutter-io.cn/packages/platform_device_id/versions
然后使用path way depandences [platform_device_id]插件,例如:

platform_device_id: 
  path: plugin/platform_device_id

然后将[platform_device_id-1.0.1]移动到项目中的插件文件夹,并将名称更改为[platform_device_id]。

相关问题