Different app names for different build flavors?

前端 未结 9 1724
-上瘾入骨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:33

    If you want to maintain localization for the app name in different flavors, then you can achieve it as follows:

    1) Specify android:label in available in AndroidManifest.xml as follows:

    
    

    2) Specify default value fo appLabel in app level build.gradle:

    manifestPlaceholders = [appLabel:"@string/defaultName"]

    3) Override the value for product flavors as follows:

    productFlavors {
        AppFlavor1 {
            manifestPlaceholders = [appLabel:"@string/flavor1"]
        }
        AppFlavor2 {
            manifestPlaceholders = [appLabel:"@string/flavor2"]
        }
    
    }
    

    4) Add string resources for each of Strings (defaultName, flavor1, flavor2) in your strings.xml. This will allow you to localize them.

提交回复
热议问题