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

后端 未结 5 1076
隐瞒了意图╮
隐瞒了意图╮ 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:57

    Figured it out. What you need to do is create a separate src folder called debug that holds the different icons. For example, if your project layout is as follows, and your launcher icon is called ic_launcher.png:

    [Project Root]
      -[Module]
        -src
          -main
            -res
              -drawable-*
                -ic_launcher.png
    

    Then to add a separate icon for the debug build type, you add:

    [Project Root]
      -[Module]
        -src
          -main
            -res
              -drawable-*
                -ic_launcher.png
          -debug
            -res
              -drawable-*
                -ic_launcher.png
    

    Then, when you build under the debug build type, it will use the ic_launcher found in the debug folder.

提交回复
热议问题