Set resValue independently of buildType or productFlavor?

懵懂的女人 提交于 2021-01-28 19:05:33

问题


Is there a way to use resValue independently of, i. e. outside of, any buildType or productFlavor?

I have some String resources in my Android project that I would like to create from within my build.gradle which don't vary with either build type or product flavor. For example, the following line stores the hash of the current git commit so that it can displayed in the settings

resValue "string", "source_git_hash", gitHash

I found that I can use the all block in either the buildTypes or the productFlavors block but this way, everything is still executed once for each build type/product flavor.

Is there a way to write the resource value globally, just once for all builds?


回答1:


defaultConfig allows you to set the same sorts of things globally that you can do no a per-product-flavor basis. So, put your resValue and buildConfigField statements in there, to define the defaults to be used for all build variants.



来源:https://stackoverflow.com/questions/50583299/set-resvalue-independently-of-buildtype-or-productflavor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!