如何设置基于两种不同的味道方面我的Android应用包的名字吗? [英] How do I set my Android app package name based on two different flavor dimensions?
问题描述
我建设我的Android应用程序的摇篮插件。我使用的香精功能创建四个不同的变种。目前,它有四个值的单一维度,但它会更合乎逻辑将它设置为两个维度,每个两个值。我有一个建筑,但是这是我遇到麻烦。
I'm building my Android app with the Gradle plugin. I'm using the flavors feature to create four different variants. At the moment, it's a single dimension with four values, but it would be more logical to set it up as two dimensions with two values each. I've got that building, but this is where I run into trouble.
我需要四个变体具有不同的包名。前三个是容易的,因为我有一个默认的,每个维度可以覆盖包,但我需要为当两个非默认尺寸在玩设置包的名称。
I need each of the four variants to have a different package name. The first three are easy since I have a default and each dimension can override the package, but I need to set a package name for when both non-default dimensions are in play.
flavorDimensions "foo", "bar"
productFlavors {
boring.flavorDimension "foo"
charm {
flavorDimension "foo"
packageName "com.example.charm"
}
strange {
flavorDimension "bar"
packageName "com.example.strange"
}
// This is the idea of what I want, but it doesn't work because there
// must be only a single dimension specified here.
charmStrange {
flavorDimension "foo", "bar"
packageName "com.example.charminglystrange"
}
}
我试图通过查找由味变种声明后,设定了,但我并没有太多的运气。我不是很熟悉的摇篮,所以我敢肯定有欺骗我还没有使用。或者,也许我可以指定的src / charmStrange / AndroidManifest.xml中
包名,让合并排序出来?这似乎是它可能会导致在未来的问题。
I tried setting it after declaration by looking up the composed flavor variant, but I didn't have much luck. I'm not very familiar with Gradle, so I'm sure there's trickery I haven't employed. Alternately, maybe I could specify the package name in src/charmStrange/AndroidManifest.xml
and let the merge sort it out? That seems like it could cause problems in the future.
推荐答案
您现在可以设置为applicationIdSuffix productFlavors:
You can now set applicationIdSuffix for productFlavors:
android {
productFlavors {
free {
applicationIdSuffix = ".free"
}
prod {
}
}
}
来源:
的http://android-developers.blogspot.ie/2015/12/leveraging-product-flavors-in-android.html
这篇关于如何设置基于两种不同的味道方面我的Android应用包的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!