New Gradle Sync is not supported due to containing Kotlin modules using an unsupported plugin versio

问题:

New Gradle Sync is not supported due to containing 
Kotlin modules using an unsupported plugin version
The Android Gradle plugin(1.3.31)supports only Kotlin Gradle plugin version 1.3.0 and higher.

原因:

gradle 配置的 kotlin插件版本和IDE(android-studio)中kotlin plugin版本不匹配,导致kotlin插件无法启用。

在android-studio中,kotlin是系统自带的plugins,android-studio根目录下plugins文件夹内的kotlin文件夹可看到
在这里插入图片描述

也可Android studio直接查看

在这里插入图片描述

解决

project : build.gradle

project : build.gradle
buildscript {
    //此处改为和IDE plugin版本匹配(此处为1.3.30或以上)
    ext.kotlin_version = '1.3.31'   

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

app : build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'//
apply plugin: 'kotlin-android-extensions' //

dependencies {
    //kotlin 支持库
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
发布了116 篇原创文章 · 获赞 38 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43290288/article/details/104338365