Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away