Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build only default (no flavors/variants)

I have a bunch of product flavors defined for my build. However in some scenarios I want to build without a flavor.

However when I try to build a release with no flavor, ie

gradlew assembleRelease

It goes through and builds all of the variants, which takes a really long time. I would like to kick off a release build and ignore all flavors. Is that possible?

I am sure I could add an empty flavor called 'default, and build that. Seems like I should not have to do that.

EDIT:

defaultConfig {
    resValue "string", "hello", "Hello default"
}

productFlavors {
    foo {
        resValue "string", "hello", "Hello Foo"
    }

    bar {
        resValue "string", "hello", "Hello Bar"
    }
}

Seems the answer at the moment is to provide your own 'default' flavor

productFlavors {

    defaults {
       // yup its empty cause I just want to build with the defaults
       // that are already defined.
    }

    foo {
        resValue "string", "hello", "Hello Foo"
    }

    bar {
        resValue "string", "hello", "Hello Bar"
    }
}
like image 297
lostintranslation Avatar asked Jul 20 '15 15:07

lostintranslation


People also ask

What are build variants?

Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Although you do not configure build variants directly, you do configure the build types and product flavors that form them.

Where is build variants in Android Studio?

To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar. For projects without native/C++ code, the Build Variants panel has two columns: Module and Active Build Variant.

How do I change a variant in build?

NOTE: By default, the Android Studio will generate "debug" and "release" Build Types for your project. So, to change a Build Type, all you need to do is just select your Build Type from the Build Variant and after the project sync, you are good to go.


1 Answers

I found out that "main" as a flavor works. So i dont need to add an additional folder with google-services.json or anything in it

productFlavors {

    main{

    }

    flav1 {
        applicationId 'id'
    }

}
like image 146
Henning Luther Avatar answered Oct 09 '22 15:10

Henning Luther