Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 542
A2i_ Avatar asked Apr 16 '15 14:04

A2i_


1 Answers

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.

like image 126
CommonsWare Avatar answered Nov 15 '22 02:11

CommonsWare