首页 > 解决方案 > 如何在 Android Studio 中使用风味

问题描述

在我的应用程序中,我想在我的应用程序中使用风味。
我将以下代码添加到build.gradle文件中,但是当在设备上运行应用程序时(单击 AndroidStudio 中的运行按钮)显示错误数据!
我的口味代码:

defaultConfig {
    applicationId "com.app.app"
    minSdkVersion 17
    targetSdkVersion 29
    versionCode 13
    versionName "1.0.13"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
    multiDexEnabled true
    //Custom flavors
    flavorDimensions "default"
    productFlavors {
        appFlav2 {
            applicationId "com.app.app.myapp2"
            resValue "string", "app_name", "App name 2"
            resValue "string", "appDescription", "description info 2"
            manifestPlaceholders = [
                    appIcon: "@drawable/logo_niaz"
            ]
        }
        appFlav3 {
            applicationId "com.app.app.myapp3"
            resValue "string", "app_name", "App name 3"
            resValue "string", "appDescription", "description info 3"
            manifestPlaceholders = [
                    appIcon: "@drawable/logo_niaz"
            ]
        }
        appFlav {
            applicationId "com.app.app"
            resValue "string", "app_name", "App name"
            resValue "string", "appDescription", "description info"
            manifestPlaceholders = [
                    appIcon: "@drawable/launcher"
            ]
        }
    }
}

但是在设备上运行应用程序时会显示这种风格的信息:appFlav3。但我的默认风味是appFlav

我该如何解决?

标签: androidandroid-studioandroid-studio-3.0

解决方案


您必须选择构建变体来运行各自的风格。要找到构建变体选项卡,请查看下面的屏幕截图。

在此处输入图像描述


推荐阅读