1

我无法让产品风味发挥作用。我想在风味中实现风味,例如,我有 2 个应用程序,我已经这样声明了它,

 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"
            ]
        }
    }

现在我想通过使用风味来“定义”开发和产品,那么我该如何实现呢?可能吗 ?我想实现这个,

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

1 回答 1

0

你必须搬到flavorDimensions外面试试这个

    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'
        }
    }
于 2020-06-08T10:24:40.603 回答