Change string resource by flavor / debug-build

前端 未结 5 1361
长情又很酷
长情又很酷 2021-02-08 21:26

Let\'s say we have strings_test.xml, which stores string values for testing and should be shown in a debug-release. When the apk gets build as a release version all values shoul

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-08 21:33

    As @Aditya Naik said it is possible using Flavors. Official doc says

    BuildType -> Flavor -> main -> Dependencies.

    This means that if a resource is declared in both the Build Type and in main, the one from Build Type will be selected.

    Note that for the scope of the merging, resources of the same (type, name) but different qualifiers are handled separately.

    This means that if src/main/res has

    • res/layout/foo.xml
    • res/layout-land/foo.xml

      and src/debug/res has

    • res/layout/foo.xml

      Then the merged resource folder will contain the default foo.xml from src/debug/res but the landscape version from src/main/res

    for more info visit Official doc - Resource Merging

提交回复
热议问题