简体   繁体   中英

Product flavor inside flavor in Android

I can not get product flavours working. I want to achieve flavor inside flavor for example, I have 2 applications by which I have declared it like this,

 productFlavors {
        abc {
            applicationId = "com.example.abc"
            versionCode 1
            versionName "0.0.1"
            resValue "string", "app_name", "abc"
            manifestPlaceholders = [
                    appIcon     : "@mipmap/ic_launcher",
                    appRoundIcon: "@mipmap/ic_launcher_round"
            ]
        }
        def {
            applicationId = "com.example.def"
            versionCode 1
            versionName "0.0.1"
            resValue "string", "app_name", "def"
            manifestPlaceholders = [
                    appIcon     : "@mipmap/ic_launcher",
                    appRoundIcon: "@mipmap/ic_launcher"
            ]
        }
    }

Now I want "def" for development and product by using flavor so how can I achieve this? Is it possible? I want to achieve this,

 productFlavors {
    dev {
        flavorDimensions "dev"
    }
    prod {
        flavorDimensions "prod"
    }
}

You have to move flavorDimensions outside try this

    flavorDimensions 'product', 'enviroment'
    productFlavors {
        abc {
            applicationId = "com.example.abc"
            versionCode 1
            versionName "0.0.1"
            resValue "string", "app_name", "abc"
            manifestPlaceholders = [
                    appIcon     : "@mipmap/ic_launcher",
                    appRoundIcon: "@mipmap/ic_launcher_round"
            ]
            dimension 'product'
        }
        def {
            applicationId = "com.example.def"
            versionCode 1
            versionName "0.0.1"
            resValue "string", "app_name", "def"
            manifestPlaceholders = [
                    appIcon     : "@mipmap/ic_launcher",
                    appRoundIcon: "@mipmap/ic_launcher"
            ]
            dimension 'product'
        }
        dev {
            dimension 'enviroment'
        }
        prod {
            dimension 'enviroment'
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM