9
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Plugin version is not the same as library version

Last updated at Posted at 2020-07-22

概要

kotlin-gradle-plugin を利用していると、プラグインとライブラリのバージョンが異なるという内容の警告が出ることがあります。

Gradle プラグインとライブラリのバージョンが同一である必要はありませんので、これは、誤検知です。

以下に、現象と対処法を示します。

現象

◆ 警告内容

Plugin version (プラグインのバージョン) is not the same as library version (ライブラリのバージョン) という内容の警告が表示されます。

例:
Plugin version (1.3.72) is not the same as library version (jdk8-1.3.72)
kotlin-warning.png

◆ 事例

以下は、実際に遭遇した事例です。

☆ Root project の build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
        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
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

☆ Sub project の build.gradle

apply plugin: 'java-library'
apply plugin: 'kotlin'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

sourceCompatibility = "1.8"
targetCompatibility = "1.8"

☆ 警告表示

Plugin version (1.3.72) is not the same as library version (jdk8-1.3.72)
kotlin.png

対処方法

誤検知なので、対処する必要はありません。

警告の抑制は以下のように行うことができます。1

// https://youtrack.jetbrains.com/issue/KT-33248
// noinspection DifferentStdlibGradleVersion
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

参考

https://youtrack.jetbrains.com/issue/KT-23744
https://youtrack.jetbrains.com/issue/KT-33248

  1. リンクのコメントは不要ですが、意図を残しておいたほうが保守者は幸せになれると思います。

9
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?