Product flavors in android do not work

I've been stuck with this all day. I created 2 options for my project and added them under buildtype in android in build.gradle. Then I created a res folder for both and changed the icons for each. When I start a project for any of the options, it shows an icon from the project.

My project structure is as follows

[project]
   [app]
      src
        main
            res
               mipmap
        flavor1
        flavor2
            res
               mipmap

and my build.gradle

    productFlavors {

    flavor1 {
        applicationId "abc"
    }

    flavor2 {
        applicationId "abc"
    }

}

sourceSets {
    flavo1 {
        res.srcDirs = ['src/flavor1/res']
    }

    flavor2 {
         res.srcDirs = ['src/flavor2/res']
    }
}

PS: nvm naming

+4
source share
1 answer

You must remove the icon from mainand leave it only in the flavor1and directories flavor2.

Also check the flavor names in build.gradle, I think it should be flavor1instead flavo1and flavor2instead staging.

: sourceSets , res .

0

Source: https://habr.com/ru/post/1693987/


All Articles