How to change app name per Gradle build type

前端 未结 10 873
慢半拍i
慢半拍i 2020-11-29 20:09

I am trying to figure out a way to be able to change my application\'s app name per build type in gradle.

For instance, I would like the debug version to have

10条回答
  •  鱼传尺愫
    2020-11-29 20:41

    We need a solution to support app name with localization (for multi language). I have tested with @Nick Unuchek solution, but building is failed (not found @string/) . a little bit change to fix this bug: build.gradle file:

    android {
        ext{
            APP_NAME = "@string/app_name_default"
            APP_NAME_DEV = "@string/app_name_dev"
        }
    
        productFlavors{
    
            prod{
                manifestPlaceholders = [ applicationLabel: APP_NAME]
            }
    
            dev{
                manifestPlaceholders = [ applicationLabel: APP_NAME_DEV ]
            }
    
        }
    

    values\strings.xml:

    
        AAA prod
        AAA dev
    
    
    

    values-en\strings.xml:

    
        AAA prod en
        AAA dev en
    
    
    

    Manifest.xml:

    
    
    

提交回复
热议问题