DEV Community

Beaver Bridge
Beaver Bridge

Posted on

local.properties의 값 가져오기

kts 기준

local.properties

API_KEY="akldfjjasdfualksjdfalsdhfulaskjhd"
Enter fullscreen mode Exit fullscreen mode

app/build.gradle.kts

import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

android {
  defaultConfig {
    buildConfigField("String", "API_KEY", readProperty("API_KEY"))
  }
}

fun readProperty(key: String): String =  gradleLocalProperties(rootDir, providers).getProperty(key)
Enter fullscreen mode Exit fullscreen mode

사용법

BuildConfig.API_KEY
Enter fullscreen mode Exit fullscreen mode

Top comments (0)