首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Kotlin编译“错误: Android插件只支持Kotlin插件版本1.3.0及更高版本。但没有kotlin_version在build.gradle?

Kotlin编译“错误: Android插件只支持Kotlin插件版本1.3.0及更高版本。但没有kotlin_version在build.gradle?
EN

Stack Overflow用户
提问于 2019-02-25 01:56:48
回答 12查看 51.6K关注 0票数 27

我尝试过克隆和构建这个项目,https://github.com/mitrejcevski/ui-testing,但是在Android中打开它时,我会得到以下构建错误:

代码语言:javascript
运行
复制
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

但是,当我单击“app”超链接时,我会被引导到模块级的build.gradle文件,该文件读取

代码语言:javascript
运行
复制
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'
}

ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher的公认答案不同,我在Gradle文件中没有看到任何ext.kotlin_version

不过,我确实看到了这样的警告:kotlin-stdlib-jre7是不可取的:

然而,我试图改变这个,但仍然得到相同的错误。我也试着增加了

代码语言:javascript
运行
复制
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'

dependencies (如上面的屏幕截图所示),但这也不能防止错误。

知道怎么解决这个问题吗?我怀疑过时的Kotlin版本是其中一个依赖项的“子依赖项”,但还无法确定是哪个依赖项。

EN

回答 12

Stack Overflow用户

回答已采纳

发布于 2019-02-25 02:14:11

变化

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

而不是

代码语言:javascript
运行
复制
org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version
票数 11
EN

Stack Overflow用户

发布于 2019-02-25 02:30:56

定义您的ext.kotlin_version

您的项目级别build.gradle应该如下所示。

代码语言:javascript
运行
复制
buildscript {
    ext.kotlin_version = '1.2.51'
    ext.android_plugin_version = '3.2.1'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$android_plugin_version"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
票数 17
EN

Stack Overflow用户

发布于 2019-07-18 07:39:53

  1. 转到工具> SDK管理器> Kotlin
  2. 安装新插件版本
  3. 确保您的项目级别build.gradle如下所示
代码语言:javascript
运行
复制
buildscript {
    ext.kotlin_version = '1.3.10' //put the version you just updated to
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54858510

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档