警告"Kotlin插件版本与库版本不同". (但它是!) [英] Warning "Kotlin plugin version is not the same as library version" (but it is!)
问题描述
我有一个Android Studio项目,其中添加了一个Java库模块,我称之为core
.我的三个Gradle构建文件如下所示.
I have an Android studio project in which I have added a Java library module, which I call core
. My three Gradle build files look like this.
project/build.gradle
project/build.gradle
buildscript {
ext.kotlin_version = '1.2.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
core/build.gradle
core/build.gradle
apply plugin: 'java-library'
apply plugin: 'kotlin'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
...
}
app/build.gradle
app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android { ... }
dependencies {
implementation project(':core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
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'
}
我遇到的问题是,在core/build.gradle
中,kotlin-stdlib-jdk7
行向我发出警告Plugin version (1.2.40) is not the same as library version (jdk7-1.2.40)
.我尝试将其更改为:
The problem I have is that, in core/build.gradle
, the kotlin-stdlib-jdk7
line is giving me the warning Plugin version (1.2.40) is not the same as library version (jdk7-1.2.40)
. I have tried changing it to:
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.40"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.40"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
但是警告仍然存在.构建仍然可以成功运行,我知道我可以毫无问题地取消警告并忽略它,但是我真的很想知道为什么会这样以及如何摆脱它.我正在使用Android Studio 3.0.1.有人知道解决方案吗?
But the warning is still there. The build still runs successfully, and I know I can surpress the warning without any problems and ignore it, but I really want to know why this is happening and how I can get rid of it. I am using Android Studio 3.0.1. Does anyone know of a solution to this?
推荐答案
这是Kotlin插件中的错误.我已经在Kotlin问题跟踪器中提交了问题.您只需忽略该消息即可.
This is a bug in the Kotlin plugin. I've filed an issue in the Kotlin issue tracker. You can simply ignore the message.
JetBrains将问题标记为 KT-23744 "Kotlin库的重复项和Gradle插件版本不同,对非JVM依赖项的检查结果为假".
JetBrains marked the issue as a duplicate of KT-23744 "Kotlin library and Gradle plugin versions are different" inspection false positive for non-JVM dependencies".
这篇关于警告"Kotlin插件版本与库版本不同". (但它是!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!