0
0

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.

GradleのVersion catalogで少し詰まったところ

Last updated at Posted at 2021-11-03

小一時間ハマりました。
Version catalogでKotlin Serializationを管理したかっただけなんですが。。。

OK

gradle/libs.versions.toml
[versions]
kotlin = "1.5.31"

[plugins]
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinserialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }

app/build.gradle
plugins {
...
    alias(libs.plugins.kotlin)
    alias(libs.plugins.kotlinserialization)
}

NG

gradle/libs.versions.toml
[versions]
kotlin = "1.5.31"

[plugins]
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }

app/build.gradle
plugins {
...
    alias(libs.plugins.kotlin)
    alias(libs.plugins.kotlin.serialization)
}

これでSync Nowするとエラーが出ます。

A problem occurred evaluating project ':app'.
> Could not find method alias() for arguments [org.gradle.accessors.dm.LibrariesForLibs$KotlinPluginAccessors@11843878] on object of type org.gradle.plugin.use.internal.PluginRequestCollector$PluginDependenciesSpecImpl.

[plugins]kotlinというaliasを使っているのでkotlin.serializationというaliasがうまく参照できないんじゃないかと思いますが、実際の所はよく分かっていません。。。

最終的な設定

kotlinserializationだと見づらかったので最終的にはこうなりました。

gradle/libs.versions.toml
[versions]
kotlin = "1.5.31"

[plugins]
kotlin-core = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }

app/build.gradle
plugins {
...
    alias(libs.plugins.kotlin.core)
    alias(libs.plugins.kotlin.serialization)
}

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?