仅构建默认值(无风味/变体)

los*_*ion 8 android gradle android-productflavors

我为我的构建定义了一堆产品风格.但是在某些情况下我想要构建没有味道.

然而,当我尝试构建一个没有味道的版本时,即

gradlew assembleRelease
Run Code Online (Sandbox Code Playgroud)

它贯穿并构建了所有变体,这需要很长时间.我想开始发布版本并忽略所有风格.那可能吗?

我相信我可以添加一个名为'default,并构建它的空味道.好像我不应该这样做.

编辑:

defaultConfig {
    resValue "string", "hello", "Hello default"
}

productFlavors {
    foo {
        resValue "string", "hello", "Hello Foo"
    }

    bar {
        resValue "string", "hello", "Hello Bar"
    }
}
Run Code Online (Sandbox Code Playgroud)

似乎现在的答案是提供你自己的'默认'味道

productFlavors {

    defaults {
       // yup its empty cause I just want to build with the defaults
       // that are already defined.
    }

    foo {
        resValue "string", "hello", "Hello Foo"
    }

    bar {
        resValue "string", "hello", "Hello Bar"
    }
}
Run Code Online (Sandbox Code Playgroud)

Hen*_*her -1

我发现“主要”作为一种味道是有效的。所以我不需要添加带有 google-services.json 或其中任何内容的附加文件夹

productFlavors {

    main{

    }

    flav1 {
        applicationId 'id'
    }

}
Run Code Online (Sandbox Code Playgroud)

  • 这会产生以下错误:评估根项目“android”时发生问题。> 配置项目“:app”时出现问题。> 具有相同键的多个条目:main=[] 和 main=[] (2认同)