问题
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