1

I have modified the gradle.properties file in the root of my android project with the following:

 myNewProp=1

And I would now like to access it via the JAVA code in my android project. But I can't seem to do it. I have tried BuildConfig, but the property isn't there.

Does anyone know how to do this?

tier1
  • 6,303
  • 6
  • 44
  • 75
Martin
  • 23,844
  • 55
  • 201
  • 327
  • Here's something similar ; http://stackoverflow.com/questions/17197636/is-it-possible-to-declare-a-variable-in-gradle-usable-in-java . Hope it's still relevant information. – harism Jul 31 '15 at 19:49

1 Answers1

0

To add a value that can be accessed in the java code you use the following:

buildConfigField "int", "myNewProp", "1"

A BuildConfig class will then be created in your project that will contain all of you values.

mattfred
  • 2,689
  • 1
  • 22
  • 38
  • so you know how I might iterate over all the properties and add them to the BuildConfig class? Also do you know how I would then access that class in Java? – Austin Apr 17 '17 at 14:32