Kotlin编译“错误:Android Gradle插件仅支持1.3.0或更高版本的Kotlin Gradle插件."但在build.gradle中没有kotlin_version? [英] Kotlin compile "ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher." but no kotlin_version in build.gradle?

查看:285
本文介绍了Kotlin编译“错误:Android Gradle插件仅支持1.3.0或更高版本的Kotlin Gradle插件."但在build.gradle中没有kotlin_version?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试克隆并构建此项目,

但是,我尝试更改此设置,但仍然遇到相同的错误.我也尝试过添加行

 实现'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21' 

依赖项(如上面的屏幕快照所示),但这也不能避免错误.

有什么办法解决这个问题吗?我怀疑过时的Kotlin版本是此处依赖项之一的子依赖项",但无法找出哪个依赖项.

解决方案

更改

org.jetbrains.kotlin:kotlin-stdlib-jre7:$ kotlin_version

代替

  org.jetbrains.kotlin:kotlin-stdlib-jdk8:$ kotlin_version 

I tried cloning and building this project, https://github.com/mitrejcevski/ui-testing, but upon opening it in Android Studio, I get the following build error:

ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher.
The following dependencies do not satisfy the required version:
root project 'ui-testing' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.21
Affected Modules: app

However, when I click the 'app' hyperlink I am led to the module-level build.gradle file, which reads

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

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "nl.jovmit"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    productFlavors {
        mock {
            flavorDimensions "default"
        }
        prod {
            flavorDimensions "default"
        }
    }

    android.variantFilter { variant ->
        if (variant.buildType.name == 'release' && variant.getFlavors().get(0).name == 'mock') {
            variant.setIgnore(true)
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation "com.android.support:appcompat-v7:$support_version"
    implementation "com.android.support:design:$support_version"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'

    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    testImplementation 'junit:junit:4.12'
}

Unlike the accepted answer of ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher, I don't see any ext.kotlin_version anywhere in the Gradle file.

I do see this warning, though, that kotlin-stdlib-jre7 is deprecated:

However, I tried changing this but still get the same error. I've also tried adding the line

implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'

to dependencies (as seen in the screenshot above), but that also didn't prevent the error.

Any idea how to fix this? I suspect that the outdated Kotlin version is a 'sub-dependency' of one of the dependencies here, but haven't been able to figure out which one.

解决方案

Change

org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version

instead of

org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version

这篇关于Kotlin编译“错误:Android Gradle插件仅支持1.3.0或更高版本的Kotlin Gradle插件."但在build.gradle中没有kotlin_version?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆