How to provide different Android app icons for different gradle buildTypes?

后端 未结 5 1078
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 19:12

I have two build types set in my gradle file: debug and release. I\'d like to be able to set a different app icon for the debug build

5条回答
  •  借酒劲吻你
    2020-11-29 19:47

    This is a handy approach although it has an important downside... both launchers will be put into your apk. – Bartek Lipinski

    The better way: InsanityOnABun's answer

    AndroidManifest.xml

    
    
        ...
    
        
    
    
    

    build.gradle

    android {
    
        ...
            productFlavors{
            Test{
                versionName "$defaultConfig.versionName" + ".test"
                resValue "string", "app_name", "App-Test"
                manifestPlaceholders = [
                        appIcon: "@mipmap/ic_launcher_test",
                        appIconRound: "@mipmap/ic_launcher_test_round"
                ]
            }
    
            Product{
                resValue "string", "app_name", "App"
                manifestPlaceholders = [
                        appIcon: "@mipmap/ic_launcher",
                        appIconRound: "@mipmap/ic_launcher_round"
                ]
            }
        }
    }
    

    the Github url:Build multi-version App with Gradle

提交回复
热议问题