Different app names for different build flavors?

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

    Another option that I actually use is change the manifest for each application. Instead of copy the resource folder, you can create a manifest for each flavour.

    sourceSets {
      main {
     }
    
      release {
        manifest.srcFile 'src/release/AndroidManifest.xml'
     }
    
      debug {
        manifest.srcFile 'src/debug/AndroidManifest.xml'
     }
    }
    

    You have to have a principal AndroidManifest in your src main that will be the principal. Then you can define a manifest with only some options for each flavour like (src/release/AndroidManifest.xml):

    
      
      
    
    

    For debug, AndroidManifest (src/debug/AndroidManifest.xml):

    
      
      
    
    

    Compiler will do a merge of the manifest and you can have a icon for each flavour.

提交回复
热议问题