LoginSignup
0
0

More than 1 year has passed since last update.

GradleのVersion catalogでcompileSdk等も管理する方法

Last updated at Posted at 2021-11-02

他のことは全部下記に書いてあります。

環境

Android Studio Bumblebee | 2021.1.1 Beta 2

BumblebeeではenableFeaturePreview('VERSION_CATALOGS')の追加が必要でした。

settings.gradle
pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

enableFeaturePreview('VERSION_CATALOGS') // <- 追加

コード

gradle/libs.versions.toml
[versions]
compileSdk = "31"
minSdk = "23"
targetSdk = "31"
app/build.gradle
android {
    compileSdk libs.versions.compileSdk.get() as Integer // or get().toInteger()
...
...
...
}

ダメだった例

下記だと怒られる。

gradle/libs.versions.toml
[versions]
compileSdk = 31
minSdk = 23
targetSdk = 31

参考

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