0

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!

  • You can't access Gradle properties like that. Try calling `getProperty('ACCESS_KEY')`. – Jorn Aug 10 '23 at 07:18

1 Answers1

0

The double quote in the gradle.properties it not required.

ACCESS_KEY=access_key

Try to print the ACCESS_KEY in the gradle file and check your build console for the output of this:

print("Access key $ACCESS_KEY")

enter image description here

If you are using the Kotlin gradle script, you can get the gradle property values as below.

val ACCESS_KEY: String by project
Samuel Robert
  • 10,106
  • 7
  • 39
  • 60