Reputation: 411
After updating Android Studio and Gradle to version 3.0 I can't build my app with 3 flavors (dbg, production, and nostore production)
In java/src folder of each flavor source set (exclude main) I have class Flavors.class with some methods specified for this source set.
But when I try to Run or Build app I have error:
Error:(9, 8) error: duplicate class: my.app.namespace.Flavors
.
Also I add to Gradle variant dimensions flavorDimensions "dbg", "prod","nostore"
and add dimension
value to each flavor section.
This is how its look:
android{
compileSdkVersion 24
buildToolsVersion '26.0.2'
...
flavorDimensions "dbg", "prod","nostore"
productFlavors {
dbg{
ndk {
abiFilters "armeabi", "x86"
}
dimension "dbg"
}
production{
ndk {
abiFilters "armeabi", "x86"
}
dimension "prod"
}
nostoreprod {
ndk {
abiFilters "armeabi", "x86"
}
dimension "nostore"
}
}
}
I don't understand what's wrong, this code look like in samples on https://developer.android.com/studio/build/build-variants.html.
And one thing, on Build Variants panel now I have only 2 variants: dbgProductionNostoreprodDebug
and dbgProductionNostoreprodRelease
but in previous version of AS and Gradle I had different variants for each flavor on this panel. (Look like AStudio try to make single build with all variants in same time or what?)
Upvotes: 2
Views: 828
Reputation: 1100
The configuration you pasted will correctly produce only 2 variants, because each of the 3 dimension only has 1 flavor and then there are 2 implicit build types (release and debug):
+-----+------------+-------------+-----------+---------------------------------+
| dbg | prod | nostore | buildType | resulting variant |
+-----+------------+-------------+-----------+---------------------------------+
| dbg | production | nostoreprod | debug | dbgProductionNostoreprodDebug |
| dbg | production | nostoreprod | release | dbgProductionNostoreprodRelease |
+-----+------------+-------------+-----------+---------------------------------+
What you probably wanted is 1 flavor dimension with 3 flavors instead:
+-----------------+-----------+--------------------+
| myDimensionName | buildType | resulting variant |
+-----------------+-----------+--------------------+
| dbg | debug | dbgDebug |
| dbg | release | dbgRelease |
| production | debug | prodDebug |
| production | release | prodRelease |
| nostoreprod | debug | nostoreprodDebug |
| nostoreprod | release | nostoreprodRelease |
+-----------------+-----------+--------------------+
Which could look like this:
...
flavorDimensions "myDimensionName"
productFlavors {
dbg{
ndk {
abiFilters "armeabi", "x86"
}
dimension "myDimensionName"
}
production{
ndk {
abiFilters "armeabi", "x86"
}
dimension "myDimensionName"
}
nostoreprod {
ndk {
abiFilters "armeabi", "x86"
}
dimension "myDimensionName"
}
Upvotes: 12