Accessing properties from gradle.properties in java?

时间:2015-07-31 19:43:50

标签: java android android-gradle

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?

1 个答案:

答案 0 :(得分: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.