I have an android project. I am attempting to call buildConfigField()
function in build.gradle
file, but the property that I have declared in gradle.properties
file cannot be found.
I have used this code in gradle.properties
:
ACCESS_KEY="access_key"
and this code in defaultConfig
block in build.gradle
file:
buildConfigField("String", "ACCESS_KEY", ACCESS_KEY)
but the last parameter is unknown! I have selected that and pressed ctrl + Q
on my keyboard, the message is No documentation found.
I have rebuilt and made my project but it still is not working!
2
Answers
The double quote in the gradle.properties it not required.
Try to print the
ACCESS_KEY
in the gradle file and check your build console for the output of this:If you are using the Kotlin gradle script, you can get the gradle property values as below.
If you are using Kotlin DSL you can use like this