Search code examples
androidandroid-studiogradleandroid-productflavors

How to configure product flavor in new gradle


I am configuring paid and free version of my app and I got below error. I already configure same before android 3 without problem.

How to fixe it please ? enter image description here

Gradle script

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "capstone.nanodegree.udacity.com.mypodcast"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }

    //flavorDimensions "default"
    flavorDimensions "free", "paid"

    productFlavors {
        free {
            applicationId "capstone.nanodegree.udacity.com.mypodcast.free"
            dimension "free"
        }

        paid {
            applicationId "capstone.nanodegree.udacity.com.mypodcast.paid"
            dimension "paid"
        }
    }
}
def AAVersion = '4.4.0'
def GLIDEVersion = '4.3.1'
def supportVersion = '26.1.0'

Solution

  • Check that there's entries for both packages in your google-services.json .....also, and this might be separate issue, I believe you should only have to define one dimension (both your flavors would have same dimension value)