Kotlinも正式に採用されたようなので、Android Studioもアップデートしようかと思って軽い気持ちでやったら、案の定エラーになったのでとりあえずビルドが出来るところまでメモしておきます。
事象
Error:All flavors must now belong to a named flavor dimension.
The flavor 'flavor_name' is not assigned to a flavor dimension.
上記の様なエラーメッセージがでて、コンパイルが通らなくなりました。
原因
The plugin now requires that all flavors belong to a named flavor dimension—even if you intend to use only a single dimension. Otherwise, you will get the following build error:
という事で、記述方法がかわりFlavor名を明示的に指定する必要があるとの事です。
解決方法
before
app/build.gradle
android{
productFlavors {
www {
}
dev {
applicationIdSuffix = '.dev'
}
stg {
applicationIdSuffix = '.stg'
}
}
}
after
app/build.gradle
android{
flavorDimensions "environment"
productFlavors {
www {
dimension "environment"
}
dev {
applicationIdSuffix = '.dev'
dimension "environment"
}
stg {
applicationIdSuffix = '.stg'
dimension "environment"
}
}
}
この様にflavorDimentionsを明示的に宣言します。