Different app names for different build flavors?

前端 未结 9 1731
-上瘾入骨i
-上瘾入骨i 2020-12-07 11:07

I have 2 build flavors, say, flavor1 and flavor2.

I would like my application to be named, say, \"AppFlavor1\" when I build for flavor1 an

9条回答
  •  余生分开走
    2020-12-07 11:20

    Remove app_name from strings.xml (else gradle will complain of duplicate resources). Then modify build file like this:

    productFlavors {
        flavor1{
            resValue "string", "app_name", "AppNameFlavor1"
        }
    
        flavor2{
            resValue "string", "app_name", "AppNameFlavor2"
        }
       } 
    

    Also make sure @string/app_name value is assigned for android:label attribute in the manifest.

    This is less disruptive than creating new strings.xml under different built sets or writing custom scripts.

提交回复
热议问题