LoginSignup
10
11

More than 5 years have passed since last update.

Android Studio 2.3 から 3.0へMigration(主にFlavor)について

Last updated at Posted at 2017-11-17

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を明示的に宣言します。

:paperclip: Refs

10
11
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11