Hemshree
Hemshree

Reputation: 31

Regarding creating flavors in Flutter

I'm making a project in which I've added two flavors dev and prod and I need to make two firebase projects for the same as I want to store different values in the database for different environments.I have made two separate firebase projects for Dev and Prod where I have two google-services.json and two google-info.plist files. To manage them I've added them in two separate folders in app/src named release and development. Whenever I try to run the flavors, it's showing an error. The error is this:

FAILURE: Build failed with an exception.

BUILD FAILED in 1s Running Gradle task 'assembleDevDebug'... Exception: Gradle task assembleDevDebug failed with exit code 1

Upvotes: 3

Views: 755

Answers (1)

ninex
ninex

Reputation: 136

I had the same issue and solved it by moving the flavor snippets to be a child of the android section, as below. Previously I had it after app{} and had the same error as above.

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        ...
    }
    signingConfigs {
       ...
    }
    buildTypes {
        ...
    }
    flavorDimensions "app"

    productFlavors{
        local {
            dimension "app"
            resValue "string", "app_name", "Removed"
            versionNameSuffix "-dev"
            applicationId "xxxx"
        }
        prod {
            dimension "app"
            resValue "string", "app_name", "Removed"
            applicationId "xxxx"
        }
    }
}

Upvotes: 8

Related Questions