A2i_
A2i_

Reputation: 398

buildConfigField VS class field? resValue VS resource

What's the advantage of putting a buildConfigField to my flavor via gradle in comparison with a Constants.java file per flavor?

Also what's the advantage of putting a resValue to my flavor via gradle in comparison with regular resources per flavor?

Thanks!

Upvotes: 5

Views: 964

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006704

What's the advantage of putting a buildConfigField to my flavor via gradle in comparison with a Constants.java file per flavor?

First, it is less typing. With buildConfigField, it's one line of Groovy code per flavor. With Constants.java, it is a separate Java class per flavor.

Second, the value could be code generated by Groovy code in the build script, and that's a whole lot easier than code generating a Java class (though the latter is certainly possible).

Also what's the advantage of putting a resValue to my flavor via gradle in comparison with regular resources per flavor?

Pretty much the same as above.

Upvotes: 8

Related Questions